Yesterday, I spent a whole day writing the company's commonly used image buttons into a widget called myimagebutton. Some techniques are involved in how to expose control properties to the vs.net property panel and display foldable properties:
1. Expose the properties of the control on the property panel:
In fact, vs. Net exposes all the public properties of the control by default (note that property is not field) to the Property panel. In addition, you can specify the default value and the category of the attribute. Below are several common attributes:
Catalogattrialog (string Catalog)
Defaultvalueattribute (Object defaultvalue)
Descriptionattribute (string description)
Typeconverter (type typeof (converterclass) // It is mainly used to convert custom type attributes to strings, so that the attribute panel can display the attribute content normally.
2. Associate the editor with a property:
You can use editorattribute to associate an Attribute Editor with attributes. For example:
Editor ("system. Web. UI. Design. imageurleditor, system. Design", typeof (system. Drawing. Design. uitypeeditor)
This attribute can be used to associate an imageurlselector to select an image and set the image URL.
3. Create a foldable property in the property panel:
This is complicated (here we are too lazy :), mainly using the designerserializationvisibilityattribute and expandableobjectconverter.
For details, refer:
Http://support.microsoft.com/default.aspx? SCID = KB; en-US; 324301