Marco
Marco

Reputation: 61

.NET PropertyGrid: Create Expandable item when value is null

I have class (ClassA) with some public properties. One of the properties (ClassBValue) is of a class type (ClassB) which has some public properties, too. Now I want to show ClassA objects in a PropertyGrid. I use the

[TypeConverter(typeof(ExpandableObjectConverter))]

Attribute for the ClassB property of ClassA.

The problem is, that the ClassBValue property is null when it is shown in the PropertyGrid. How can I enable the user to create a ClassB object within the PropertyGrid?
The user should be able to set a value for the ClassBValue and edit the sub-properties and also to delete the value (set it to null).

Upvotes: 2

Views: 1064

Answers (1)

leppie
leppie

Reputation: 117330

You would need a custom type converter for that.

Upvotes: 1

Related Questions