Showing a UITypeEditor at Run-time

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
 
D

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top