views:

330

answers:

1

Hi to all!

I develop a custom control that have some field like below:

ControlKind, Field1 , Field2

I want to change attribute of one of field per controlKind,
Like: if controlKind == useField1, then Field1 show and Field2 hidde in properyGrid (or readonly or filter)

can i do it ?

Thanks in advance

+3  A: 

Implement ICustomTypeDescriptor, or register a TypeDescriptionProvider and return a custom type descriptor from that, or apply TypeConverterAttribute.

In all three cases, you need to implement / override the GetProperties method to return a filtered subset of the actual properties. (In the TypeConverter approach, you must also override GetPropertiesSupported to return true.)

itowlson
for the TypeConverter case (which is by far the simplest, btw), simply inherit from ExpandableObjectConverter and you get much for free.
Marc Gravell