问题描述
返回到VS2008中的WinForms很长一段时间以后。在VS2008速成版OOD的问题修修补补。
Returning to WinForms in VS2008 after a long time.. Tinkering with a OOD problem in VS2008 Express Edition.
我需要一些控制是只显示部件。用户不应该能够改变这些控件的值...小部件是由周期性的更新Tick事件进行更新。我依稀记得那里是你可以设置有此行为的只读属性......现在不能找到它。
I need some controls to be "display only" widgets. The user should not be able to change the value of these controls... the widgets are updated by a periodic update tick event. I vaguely remember there being a ReadOnly property that you could set to have this behavior... can't find it now.
在已启用属性设置为false:灰色了控制内容。我想控制到正常观看。
中的锁定属性设置为false:似乎是保护意外扭曲在Visual窗体设计器控制用户
The Enabled property set to false: grays out the control content. I want the control to look normal.The Locked property set to false: seems to be protecting the user from accidentally distorting the control in the Visual Form Designer.
我在想什么?
推荐答案
对于一些典型的WinForms控件:
For some typical winforms controls:
的
这也是一个很好的提示保存的外观:
This is also a good tip to preserve the appearance:
Color clr = textBox1.BackColor;
textBox1.ReadOnly = true;
textBox1.BackColor = clr;
这篇关于如何使Windows窗体控件只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!