I'm tweaking a WinForms application. This application has a Form that contains a PropertyGrid. An object is assigned to the SelectedObject property so that the property grid displays the properties for the object.
The type of the object assigned has a property that carries an EditorAttribute specifying a UITypeEditor.
This implementation of UITypeEditor returns UITypeEditorEditStyle.Drop in its override of GetEditStyle method. Its EditValue method displays a ListBox from which a value for the instance property can be assigned.
All well an good so far.
Now I have an additional requirement which calls for the available items in the list to be modified based on other state held by the Form hosting the PropertyGrid. I can't work out how to get this contextual information to the EditValue method.
There doesn't seem to be anything on the context parameter even if I try casting it to more specific types. Neither can I work out how to add some other Service to retrieve from the provider.
Any ideas?
I wonder if what you are trying to do would would better as a
TypeConverterviaGetStandardValues? But either way, bothcontext.Instanceandcontext.PropertyDescriptorseem to be populated in a quick test (for bothGetEditStyleandEditValue):Or as a type-converter: