Creating a web control with an expandable property in the designer by using C #.

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.