在C#中的用户控件Text属性 [英] Text property in a UserControl in C#
本文介绍了在C#中的用户控件Text属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框内部控制。我想使用户控件的Text属性和文本框的Text属性有着直接的关系。我意识到的第一件事是没有被显示在该用户的属性文本。然后,我添加了可浏览(真)属性。
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;
}
}
现在,文本将显示一段时间,但随后被删除。这是因为信息没有 xxxx.Designer.cs
文件中自动写入。这怎么behviour改变?
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?
推荐答案
您需要更多的属性:
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Bindable(true)]
public override string Text
这篇关于在C#中的用户控件Text属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文