Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text property in a UserControl in C#

I have a control with a inner TextBox. I want to make a direct relationship between the Text property of the UserControl and the Text property of the TextBox. The first thing I realized is that Text was not being displayed in the Properties of the UserControl. Then I added the Browsable(true) attribute.

[Browsable(true)] public override string Text {     get     {         return m_textBox.Text;     }      set     {         m_textBox.Text = value;     } } 

Now, the text will be shown for a while, but then is deleted. This is because the information is not written automatically within the xxxx.Designer.cs file. How can this behviour be changed?

like image 881
yeyeyerman Avatar asked May 21 '10 10:05

yeyeyerman


People also ask

What is Property in user control in C#?

User Control properties are used to set the values of a User Control from the parent page.

Which property show the text on control in asp net?

Remarks. Use the Text property to specify or determine the text content of the Label control. This property is commonly used to programmatically customize the text that is displayed in the Label control.


1 Answers

You need more attributes:

[EditorBrowsable(EditorBrowsableState.Always)] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Bindable(true)] public override string Text { get; set; } 
like image 190
Hans Olsson Avatar answered Oct 14 '22 14:10

Hans Olsson