【发布时间】:2015-08-01 22:49:30
【问题描述】:
我要做的是在文本框中没有文本并且文本确实占据所需文本框时禁用按钮
if (NamePath.Text.Length == 0 && ThemePath.Text.Length == 0)
{
button1.Enabled = false;
}
else if (NamePath.Text.Length > 0 && ThemePath.Text.Length > 0)
{
button1.Enabled = true;
label7.Text = "Press Button To Find a Match";
label7.ForeColor = Color.PaleGreen;
}
编辑:
我尝试了另一种方法,将文本添加到文本框以尝试触发它,但仍然没有运气:/
if (NamePath.Text == "yes" && ThemePath.Text == "yes")
{
button1.Enabled = false;
}
if (NamePath.Text != "yes" && ThemePath.Text != "yes")
{
button1.Enabled = true;
label7.Text = "Press Button To Find a Match";
label7.ForeColor = Color.PaleGreen;
}
【问题讨论】:
-
你的问题是什么?
-
您能否阐明您希望在代码中看到的内容以及实际看到的内容?我已经尝试过回答,但我正在做出一些假设。
-
触发了什么事件(运行上面的代码)以及如何连接它们?
-
我在公共 Form1() 中有它,所以它在打开时启动,它按照代码的指示禁用,它启用它的能力无法正常工作。
标签: c# if-statement text