Tag Archives: Generic Type Editor

using UITypeEditor on Winform with a Generic Type Editor

If you are a developer, than I guess Property Grid isn’t a stranger to you. Property grid  has been used in win form designer to manipulate the properties of the selected object in the designer. Property Grid can also be used as control to use on your own form , to give user a compact way to manipulate properties( It is not available in the tool box , you will need to add it by using choose item option in Visual Studio). Property Grid has an interesting feature , it can show Type specific editor if one is available . e.g editing a color value will result in opening a color box, similarly for font and other types. If you want to have an editor for your custom data type , then you can implement a UITypeEditor and bind it to the target type using attirbute.

Some times you don’t use the whole Property Grid , but only want to display a certain type editor on your form, e.g you want to give user , option to edit a font , and want to utilize the font editor . How this can be achieved? Well, its simple , all you need to do is implement the IWindowFormsEditorService interface and provide a form or control to host the uitype editor. 😀

I came across a very insightful article on DevX about implementing these requirements. Emmanuel Tissandier has not only explained the underlying architecture of UITypeEditor  but also impelement a control which can be used to host any UITypeEditor, and so you can have a generice type editor.

Article can be accessed here:  Build A Property Editor That Can Edit Any .Net Type