Properties with subproperties in propertygrid?


G

Guest

Hi to all,

In a .net 2.0 program, I'm trying to use the property grid. When the
property grid displays an object, it successfully displays its properties.
What I'd like to ask is: How can I make a property to have "sub-properties"
on the propertygrid? Something like (Application Settings) that is displayed
when WindowsForm Controls are selected or something like Font which has
subproperties ('size', 'face', 'color' etc.).

Thanks for any help!
 
Ad

Advertisements

S

Stoitcho Goutsev \(100\)

Kingherc,

The easiest way is to attribute the type or property with
ExpandableObjectConverter.
Normally you create your own conveter that derives from this type.

[TypeConverter(MyTypeExpandableConverter)]
MyType Prop
{
.....
}

Normally in the converter class you need to override couple of methods in
order to convert from/to string.
 
G

Guest

Hi,

I tried doing the same thing for displaying a custom class derived from
ApplicationSettingsBase (called EngineSettings). EngineSettings again
contained another class derived from ApplicationSettingsBase (called
GroupSettings).

By using the default ExpandableObjectConverter for the GroupSettings class I
have been unable to expand the GroupSettings property of EngineSettings when
displayed in a propertygrid.

If EngineSettings does not inherit from ApplicationSettingsBase, the
GroupSettings property DOES expand, but not when it inherits from it.

Does my GroupSettings class HAVE to have a custom TypeConverter? Is it not
possible to use the ExpandableObjectConverter?

Thanks!

-Torbjørn

Stoitcho Goutsev (100) said:
Kingherc,

The easiest way is to attribute the type or property with
ExpandableObjectConverter.
Normally you create your own conveter that derives from this type.

[TypeConverter(MyTypeExpandableConverter)]
MyType Prop
{
.....
}

Normally in the converter class you need to override couple of methods in
order to convert from/to string.


--
HTH
Stoitcho Goutsev (100)
Kingherc said:
Hi to all,

In a .net 2.0 program, I'm trying to use the property grid. When the
property grid displays an object, it successfully displays its properties.
What I'd like to ask is: How can I make a property to have
"sub-properties"
on the propertygrid? Something like (Application Settings) that is
displayed
when WindowsForm Controls are selected or something like Font which has
subproperties ('size', 'face', 'color' etc.).

Thanks for any help!
 
Ad

Advertisements

G

Guest

Hi again,

I finally figured out my problem: I had forgotten to do "new" on my custom
settings, since (of course) ApplicationSettingsBase does not do that for you.

Cheers,
Torbjørn

Torbjørn said:
Hi,

I tried doing the same thing for displaying a custom class derived from
ApplicationSettingsBase (called EngineSettings). EngineSettings again
contained another class derived from ApplicationSettingsBase (called
GroupSettings).

By using the default ExpandableObjectConverter for the GroupSettings class I
have been unable to expand the GroupSettings property of EngineSettings when
displayed in a propertygrid.

If EngineSettings does not inherit from ApplicationSettingsBase, the
GroupSettings property DOES expand, but not when it inherits from it.

Does my GroupSettings class HAVE to have a custom TypeConverter? Is it not
possible to use the ExpandableObjectConverter?

Thanks!

-Torbjørn

Stoitcho Goutsev (100) said:
Kingherc,

The easiest way is to attribute the type or property with
ExpandableObjectConverter.
Normally you create your own conveter that derives from this type.

[TypeConverter(MyTypeExpandableConverter)]
MyType Prop
{
.....
}

Normally in the converter class you need to override couple of methods in
order to convert from/to string.


--
HTH
Stoitcho Goutsev (100)
Kingherc said:
Hi to all,

In a .net 2.0 program, I'm trying to use the property grid. When the
property grid displays an object, it successfully displays its properties.
What I'd like to ask is: How can I make a property to have
"sub-properties"
on the propertygrid? Something like (Application Settings) that is
displayed
when WindowsForm Controls are selected or something like Font which has
subproperties ('size', 'face', 'color' etc.).

Thanks for any help!
 

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