lable只读?文本框有一个ReadOnly属性,设置后用户不能输入但代码仍然可以修改Text属性 你要的lable只读应该是不能修改Text属性了,如果lable不能修改Text属性,那这个lable还有什么用? public class ReadOnly : Label { public override string Text { get { return base.Text; } } }
public class ReadOnly : Label { public string Text { get { return base.Text; } } }
你要的lable只读应该是不能修改Text属性了,如果lable不能修改Text属性,那这个lable还有什么用? public class ReadOnly : Label
{
public override string Text
{
get
{
return base.Text;
}
}
}
{
public string Text
{
get
{
return base.Text;
}
}
}
如果“只读”了,你怎么改它,我感觉你要实现的是在外部不让改动。
如果是form或其它可视控件,把它设置为私有或保护,不失为一种选择。连内部也不让也,只有用楼上的方法了,你把控件重载了。这样,谁也改不了它,你只有再实现一个函数在需要的时间改动它了。但那个“只读”吗? 还是被改动了。
难道label不是只读的?
label1.Text ="草你奶奶,你要敢改我这个LABEL的值,你生儿子就没P眼!";