Showing a UITypeEditor at Run-time

  • Thread starter Thread starter Daniel Gackle
  • Start date Start date
D

Daniel Gackle

How can I get a custom UITypeEditor to show up in the PropertyGrid at
runtime?

The examples out there all seem to work at design time inside Visual
Studio, but if you put a PropertyGrid control on your form and set
SelectedObject at runtime, the same custom editor doesn't show up.

The closest thing I've found in searching the newsgroups was the
following comment by Shawn Burke . I would be very grateful if anyone
could expand on this or point me in the direction of some sample code.
Take a look at IWindowsFormsEditorService. You'll need to implement this,
get the editor from an object by calling TypeDescriptor.GetEditor(object,
typeof(UITypeEditor)), and then calling it with an IServiceProvider that can
create your IWindowsFormsEditorService implementation.

Thanks,
Daniel Gackle
 
Sqwawk! It does work. When you don't make stupid mistakes.

If anybody ever has this problem, make sure you don't do what I did:

propertyGrid1.SelectedObject = myCustomEditorObject;

when what you really mean is:

propertyGrid1.SelectedObject = objectWithSomePropertyOfMyCustomEditorType;
 
Back
Top