开发者

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

开发者 https://www.devze.com 2022-12-07 23:56 出处:网络
I have a custom user control (a webcontrol in this case) that has a开发者_如何学Go property of type Collection

I have a custom user control (a webcontrol in this case) that has a开发者_如何学Go 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 designer when I add this control to a webform. It does show up already, but I'd like it to have a [...] button in the property window and when you clik it, it gives you the ability to enter multiple strings. Probably this should also be reflected in the markup someway.

Can anyone point me in the right direction?

PS The property doesn't have to be of the type Collection, if some other generic collection type would be more suitable...


System.Windows.Forms.Design.StringCollectionEditor is what you're 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; }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消