使文本框"ReadOnly"使用c#中的if语句
本文关键字:quot 中的 if 语句 使用 文本 ReadOnly | 更新日期: 2023-09-27 18:12:28
我想知道是否有一个可能的代码来做这样的事情:
if (textBox1.Text == "No")
{
//some code to make textBox2 ReadOnly
}
试试这个:
textbox1.ReadOnly = true;
或:
textbox1.Enabled = false;
如果是ASP则使用TextBox.ReadOnly
属性。Net应用程序,对于WinForm是
如果是WinForm则使用TextBox.ReadOnly
属性。
代码将是相同的,如:
if (textBox1.Text == "No")
{
textBox1.ReadOnly = true;
}
参见:如何:创建只读文本框(Windows窗体)
if (textBox1.Text == "No")
{
textBox1.Enabled=false
}