我正在尝试从智能感知中隐藏Text
控件的TextBox
属性的属性。
我尝试了以下操作,但是我收到编译错误,抱怨Text
属性未在基类中设置为虚拟。我不是要删除该属性,只是将其隐藏在Intellisense中。有什么想法吗?
public class MyTextBox:TextBox
{
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
}
答案 0 :(得分:2)
如果它不是虚拟的,你可以使用new
关键字隐藏它。
像这样:
public class MyTextBox:TextBox
{
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
public new string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
}