What a great technique! Being able to take advantage of the design-time features of the .NET Framework at runtime, to present users with property editors can certainly simplify development when you need to let users pick a value or choose some other arbitrarily complex values. What do you think of this article? Will you use the GenericValueEditor class or any of the techniques shown in your own applications? Let us know in the .NET Technical forum on DevX
Build a Property Editor That Can Edit Any .NET Type
This article describes how to create a Windows Forms control that leverages the power of the .NET Framework's UITypeEditor and TypeConverter classes at runtime to create a control that can display and edit the values of all .NET types.
by Emmanuel Tissandier
May 6, 2004
he .NET framework offers a large set of controls for people who are creating Windows Forms applications: the TextField control for editing text, the CheckBox for Boolean values, the ComboBox for choosing a value between a list, and even a DateTimePicker control for selecting dates, among many others. But even this rich control set doesn't cover all the needs of every application. For example, the platform does not provide a simple control for letting users choose a colorand of course there's no control for editing user-defined types. Creating such controls can be very time consuming.
This article explains how to create a Windows Forms control that can edit and represent values of all .NET types, called the GenericValueEditor. It exploits two notions present in the .NET framework: type editors (UITypeEditor) and type converters (TypeConverter). With such a control, programmers can use either the predefined UITypeEditors provided by the framework or custom design-time editors they have developed, and use them in a final application to provide rich runtime editors.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!