【发布时间】:2010-06-10 17:07:11
【问题描述】:
当您从工具箱向表单添加标签时,其文本默认为项目名称(label1、label2 等)。如何使用自定义控件实现这一点?到目前为止,我有以下内容,它允许我通过属性窗口更改文本:
private string _text;
[BrowsableAttribute(true)]
public override string Text
{
get { return _text; }
set
{
_text = value;
lblID.Text = _text;
}
}
显然上面的代码按原样工作,但我不知道为什么。 Text 是否自动默认为对象的名称?这个问题仍然适用于不覆盖 Text 的其他属性。
【问题讨论】:
标签: c# properties attributes custom-controls