Question

I needed to add enum properties at runtime to be displayed inside the proertygrid, this lead me to this page

Properties generated at runtime (PropertyGrid.SelectedObject)

which did the job as I wanted. I tested this with a static enum, but I also need to provide user defined values to the enum at runtime. I do understand that I need to change the

 public override StandardValuesCollection
             GetStandardValues(ITypeDescriptorContext context)

method, but the problem is that the context.instance property shows all the properties inside the bag described in the mentioned stackoverflow page. So if I have 5 properties the instance property will have an array of 5 properties; how can I find out which one is the one I should mess with? Is there any other way to provide the values to the enum besides populating it inside the GetStandardValues() method?

cheers, ES

Was it helpful?

Solution

the ITypeDescriptorContext object has a PropertyDescriptor.Name property

context.PropertyDescriptor.Name

this will show the element.

-ES

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top