How do you create a user control property of type collection <string> editable / customizable in visual studio designer

I have a custom control (in this case it is a webcontrol) that has a property of type Collection

public class example : public System.Web.UI.UserControl
{
    public Collection<string> ThisIsTheCollection { get; set; }
}

      

I would like to be able to edit this property in the designer when I add this control to the web form. This is already showing up, but I would like to have a [...] button in the properties window, and when you click it, it gives you the ability to enter multiple lines. This should probably be reflected in the markup as well.

Can anyone point me in the right direction?

PS The property does not have to be of type Collection if some other generic collection type would be more appropriate ...

+2


source to share


2 answers


System.Windows.Forms.Design.StringCollectionEditor is what you are looking for. Assign it to the property using the Editor attribute.



[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design",
"System.Drawing.Design.UITypeEditor, System.Drawing")] 
public Collection<string> ThisIsTheCollection { get; set; }

      

+2


source


Derive the new class from UITypeEditor and apply to the property using the Editor attribute .



0


source







All Articles