Properties with subproperties in propertygrid?

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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.
 
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!
 
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!
 
Back
Top