2

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).

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Marco
  • 61
  • 1
  • 3

1 Answers1

1

You would need a custom type converter for that.

leppie
  • 115,091
  • 17
  • 196
  • 297
  • 1
    I already tried to implement a type converter inherited from ExpandableObjectConverter that converts from/to string. But then the user has to enter a string in the correct format to create ClassB object value. That is not intuitive and ergonomic. Any hints for doing it better? – Marco Jun 24 '10 at 11:35