The property editor here means that you can implement the pop-up dialog box and the dropdown UI as mentioned above. Nonsense do not say the following we introduce.
1, the form of pop-up dialog box
In this example, I use the string type of properties to display the version of the information, you can casually write various types of properties, here only need to specify the editor of the property can be changed.
First we're going to create a string type of property with the following code:
You may have noticed a property in this attribute EditorAttribute (typeof (Appverconverter), typeof (System.Drawing.Design.UITypeEditor)), Everyone can refer to MSDN I don't have to say much here, so let's see how appverconverter this class is going to be. The specific code is as follows:
<summary>
Custom UI Property Editor (pop-up message)
</summary>
public class AppVerConverter:System.Drawing.Design.UITypeEditor
{
<summary>
Override this method to return the type of the editor.
</summary>
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle ( System.ComponentModel.ITypeDescriptorContext context)
The explanation here is that our property editor must inherit from System.Drawing.Design.UITypeEditor, or else we won't be able to display the UI. The return value of the Uitypeeditoreditstyle method determines the type of the Modifier property editor you can refer to MSDN I'm not going to say much here. After compiling, you can see the following picture:
2. Type of dropdown UI
The dropdown UI type is primarily provided to the user with a simple interface to select the attributes to be determined, a way that provides a very user-friendly interface to the user. For the following example, we first define the attribute of a point type in which, by default, this type of property is expanded to allow the user to edit it. Here we extend his function not only to change the value by direct input, but also to pull out a control that allows the user to determine the exact value based on the mouse position on the control. The following specific code:
if (e.button==system.windows.forms.mousebuttons.left)
This._iws. Closedropdown ();
}
}
The above code degree is very simple, I believe you will be able to understand, if there is not understand the place to see help, it explains very clearly.
In writing the property editor we all need to overwrite the EditValue method, do you notice the parameter of object value? This parameter is actually a boxed attribute value, and we can also return a boxed value to determine which property has been modified when we have finished processing this value. In the above two examples we simply use this value, you understand this content will be able to make a more personalized editor.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.