我在想,如果有可能的代碼做這樣的事情:在C#中使用if語句使文本框「ReadOnly」?
if (textBox1.Text == "No")
{
//some code to make textBox2 ReadOnly
}
我在想,如果有可能的代碼做這樣的事情:在C#中使用if語句使文本框「ReadOnly」?
if (textBox1.Text == "No")
{
//some code to make textBox2 ReadOnly
}
if (textBox1.Text == "No")
{
textBox1.Enabled=false
}
使用TextBox.ReadOnly
財產如果ASP.Net應用,對於WinForm的是
如果WinForm然後使用TextBox.ReadOnly
屬性。
代碼將爲兩人都喜歡是一樣的:
if (textBox1.Text == "No")
{
textBox1.ReadOnly = true;
}
試試這個:
textbox1.ReadOnly = true;
或者這樣:
textbox1.Enabled = false;
肯定。 'textBox1.ReadOnly = true;' – 2013-05-07 04:46:57
WinForms?的WebForms?其他? (包括這個作爲標籤比'if-statement'或'statement'更有用。) – user2246674 2013-05-07 04:49:12