使文本框不可编辑 [英] Make TextBox uneditable
问题描述
我想让我的表单上的一些 TextBox
无法编辑,但我希望 text
清晰(黑色而不是灰色),这就是为什么我不想使用
myTextBox.Enabled = false;
不知何故,我希望它被禁用,但前景色不是灰色.
有人知道吗?
使用 TextBox.ReadOnly
属性
TextBox.ReadOnly = true;
对于非灰色背景,您可以更改 TextBox.BackColor
属性为 SystemColors.Window
Color
textBox.BackColor = System.Drawing.SystemColors.Window;
<块引用>
当这个属性设置为true时,控件的内容不能由用户在运行时更改.将此属性设置为 true,您仍然可以在代码中设置 Text 属性的值.你可以用这个功能,而不是禁用具有 Enabled 属性的控件允许复制内容并显示工具提示.
I want to make some TextBox
es on my form uneditable, but I want the text
to be clear (black not gray) and that's why I do not want to use
myTextBox.Enabled = false;
Somehow I want it to be disabled but with non-gray fore-color.
Does anyone have any clue?
Using the TextBox.ReadOnly
property
TextBox.ReadOnly = true;
For a Non-Grey background you can change the TextBox.BackColor
property to SystemColors.Window
Color
textBox.BackColor = System.Drawing.SystemColors.Window;
When this property is set to true, the contents of the control cannot be changed by the user at runtime. With this property set to true, you can still set the value of the Text property in code. You can use this feature instead of disabling the control with the Enabled property to allow the contents to be copied and ToolTips to be shown.
这篇关于使文本框不可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!