Custom User Control and VS.NET 2005
-
I've created a customized control that is basically a textbox with some labels. Among other things, I'm trying to expose a couple attributes of the textbox (called myText). Within the class of the user control, I've put
public bool Multiline { get { return myText.Multiline; } set { myText.Multiline = value; } }
This is all fine, and I can modify this within code, but how do I get this property to show up in the properties window in the .NET designer? Is there some special tag I need to put before it? -
I've created a customized control that is basically a textbox with some labels. Among other things, I'm trying to expose a couple attributes of the textbox (called myText). Within the class of the user control, I've put
public bool Multiline { get { return myText.Multiline; } set { myText.Multiline = value; } }
This is all fine, and I can modify this within code, but how do I get this property to show up in the properties window in the .NET designer? Is there some special tag I need to put before it?That's all you need, if you want to set the description (displayed at the bottom of the property grid) then use the [Description("Your description")] tag, likewise there's a category attribute (when the property grid is in the category view) and a few others such as designer (not applicable to this property). But basically any property is by default displayed in the property grid. To hide it use the [Browsable(false|true)] attribute.
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
-
I've created a customized control that is basically a textbox with some labels. Among other things, I'm trying to expose a couple attributes of the textbox (called myText). Within the class of the user control, I've put
public bool Multiline { get { return myText.Multiline; } set { myText.Multiline = value; } }
This is all fine, and I can modify this within code, but how do I get this property to show up in the properties window in the .NET designer? Is there some special tag I need to put before it?hi Drew McGhie! :) basically, your code is already fine... maybe the "myText" textbox is not initialized? if the initialization of this textbox was done on the InitializeComponent method... there would be no problem. perhaps you do the initialization by demand? hope this helps! :) microsoc :cool:
-
That's all you need, if you want to set the description (displayed at the bottom of the property grid) then use the [Description("Your description")] tag, likewise there's a category attribute (when the property grid is in the category view) and a few others such as designer (not applicable to this property). But basically any property is by default displayed in the property grid. To hide it use the [Browsable(false|true)] attribute.
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
Turns out all I needed to do was re-open the designer where I was trying to use the custom form. That got it showing up. Anyways, thanks for the help, and the advice on [Description()]