Possible duplicate:
Text property in UserControl in C #
How to mark Text property for UserControl as view?
The .NET UserControl class has a Text .
Unfortunately, the Text property for UserControl not viewable :
// // // Returns: // The text associated with this control. [Bindable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public override string Text { get; set; }
In my UserControl I want to open the Text property (i.e. make it viewable) in the properties window. I tried to blindly declare it viewable:
[Browsable(true)] public override string Text { get; set; }
and now it appears in the properties window, but now it does nothing.
I tried blindly calling base.Text to return functionality:
[Browsable(true)] public override string Text { get {return base.Text;} set { base.Text = value; this.Invalidate(); } }
and now the property performs a function at design time, but the value of the property is not stored in the code of Form.Designer.cs and InitalizeComponent .
What is the correct way to display a UserControl Text property so that it:
- available for viewing in the properties window
- is functional
- saved in form designer
and, as a bonus:
Ian boyd
source share