2013-05-07 26 views
-1

我在想,如果有可能的代碼做這樣的事情:在C#中使用if語句使文本框「ReadOnly」?

if (textBox1.Text == "No") 
{ 
    //some code to make textBox2 ReadOnly 
} 
+1

肯定。 'textBox1.ReadOnly = true;' – 2013-05-07 04:46:57

+0

WinForms?的WebForms?其他? (包括這個作爲標籤比'if-statement'或'statement'更有用。) – user2246674 2013-05-07 04:49:12

回答

0
if (textBox1.Text == "No") 
{ 
    textBox1.Enabled=false 
} 
1

試試這個:

textbox1.ReadOnly = true; 

或者這樣:

textbox1.Enabled = false;