if (comboBox1.Text == "TCP Server")
{
this.button1.Text = "连接";
textBox1.Enabled = true;
textBox2.Enabled = true;
comboBox1.Enabled = true;
}
else
{
switch (this.button1.Text)
{
case "断开":
this.button1.Text = "连接";
textBox1.Enabled = true;
textBox2.Enabled = true;
comboBox1.Enabled = true;
break;
case "连接":
this.button1.Text = "断开";
textBox1.Enabled = false;
textBox2.Enabled = false;
comboBox1.Enabled = false;
break;
default:
break;
}
}
代码基本我写完了,但是if里面我写的不对,我希望点击TCP Server 时候swtich不要循环了,就是没有任何变化?
按你的代码
if (comboBox1.Text == "TCP Server")不过我在调试软件时候if语句没用还是进入switch,不知道为什么?
追答这不科学,你在if (comboBox1.Text == "TCP Server")这一句的位置下个断点,看看comboBox1.Text到底是什么?
追问问题已经解决了,谢谢。
本回答被提问者采纳