次の方法で共有


How to: Implement a UI Type Editor

Caution

This content was written for .NET Framework. If you're using .NET 6 or a later version, use this content with caution. The designer system has changed for Windows Forms and it's important that you review the Designer changes since .NET Framework article.

In some situations, a simple value-to-string conversion that allows a property to be displayed as text in the property browser might not be adequate. Also, a string-to-value configuration style may not be adequate for some types. For instance, in the case of a color property, a visual representation is more desirable. A UI type editor can provide a visual representation of a property value in a property grid control, such as a design-time property browser. A UI type editor can also provide a custom user interface for configuring the value or values of an object of a particular type.

Note

An EditorAttribute is applied to a type or to a property to associate the type or the property with a UI type editor.

To implement a custom UI type editor for Windows Forms

  1. Define a class that derives from System.Drawing.Design.UITypeEditor.

  2. Override the EditValue method to set up properties of the user interface. This method is overloaded.

  3. Override the GetEditStyle method to inform the property browser about the editing support that you will provide.

For a complete sample, see Walkthrough: Implementing a UI Type Editor.

Compiling the Code

  • When you develop your custom UITypeEditor, it is recommended that you set the build number to increment with each build. This prevents older, cached versions of your UITypeEditor from being created in the design environment.

See Also

Tasks

How to: Create a UI Type Editor

Reference

UITypeEditor

Other Resources

Extending Design-Time Support