【发布时间】:2017-05-26 00:46:39
【问题描述】:
如果这三个布尔值为真,我需要激活按钮
public bool isFileOpened = false;
public bool isDrive = false;
public bool isPrice = false;
它们在两个文本框被填充后变为真,并且 filePath 字符串不为空
private void textBox1_TextChanged(object sender, EventArgs e) {
drive = CheckIntInput(sender, "not valid");
if (drive != 0) {
isDrive = true;
}
}
private void textBox2_TextChanged(object sender, EventArgs e) {
price = CheckIntInput(sender, "not valid");
if (price != 0) {
isPrice = true;
}
}
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) {
filePath = openFileDialog1.FileName;
label1.Text = filePath;
isFileOpened = true;
}
CheckIntInput 方法从文本框返回数字,如果不能将字符串转换为数字,则返回 0
以及我如何制作这样的东西:
if (isFileOpened && isDrive && isPrice) {
showButton.Enabled = true;
}
我想在所有三个布尔值都为真后立即启用按钮,这三个字段可以用不同的方式输入,比如
- 文本框1
- 文本框2
- 打开文件对话框1
或
- 文本框1
- 打开文件对话框1
- 文本框2
【问题讨论】: