Complex properties in custom controls

G

Guest

I have a control, let's call it MyControl. One of the properties of
MyControl is MyControlStyle. MyControlStyle is a class with a number of
properties. MyControl always has a valid instance of MyControlStyle (it is
instantiated in the field declaration).

In the property grid, I want to lay out the items in MyControlStyle when
someone selects a MyControl on the form. They are all simple data types and
don't require any sort of custom designers or anything in themselves.

How do I get the properties of MyControlStyle to show up in the property
grid without duplicating the properties in MyControl. I mean, if I have to
pass the properties through like that then it's kind of pointless to have
the MyControlStyle class separate.

Thanks.

Pete
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi (e-mail address removed),

You need to implement a type converter for your type. If you want the type
to be expandable in the PropertyGrid let your type converter to inherit from
ExpandableObjectConverter.


For more info and example look at 'Getting the Most Out of the .NET
Framework PropertyGrid Control' article in MSDN there a section called
'Adding Expandable Property Support'

you can find this article at
MSDN offline:
ms-help://MS.MSDNQTR.2003APR.1033/dndotnet/html/usingpropgrid.htm

MSDN online:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp
 
G

Guest

Thanks. I was sure there was something like that in there, but I couldn't
find it.

Thanks again.

Pete

Stoitcho Goutsev (100) said:
Hi (e-mail address removed),

You need to implement a type converter for your type. If you want the type
to be expandable in the PropertyGrid let your type converter to inherit from
ExpandableObjectConverter.


For more info and example look at 'Getting the Most Out of the .NET
Framework PropertyGrid Control' article in MSDN there a section called
'Adding Expandable Property Support'

you can find this article at
MSDN offline:
ms-help://MS.MSDNQTR.2003APR.1033/dndotnet/html/usingpropgrid.htm

MSDN online:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp

--
HTH
Stoitcho Goutsev (100) [C# MVP]


I have a control, let's call it MyControl. One of the properties of
MyControl is MyControlStyle. MyControlStyle is a class with a number of
properties. MyControl always has a valid instance of MyControlStyle (it is
instantiated in the field declaration).

In the property grid, I want to lay out the items in MyControlStyle when
someone selects a MyControl on the form. They are all simple data types and
don't require any sort of custom designers or anything in themselves.

How do I get the properties of MyControlStyle to show up in the property
grid without duplicating the properties in MyControl. I mean, if I have to
pass the properties through like that then it's kind of pointless to have
the MyControlStyle class separate.

Thanks.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top