如果语句不起作用,屏蔽文本框C#Winforms为空?

时间:2021-08-07 20:53:59

Hello everyone im currently trying to run an IF statement within C# WinForms that checks whether two masked textboxes have been completed and in that scenario a button will then appear to the user. This is my code:

大家好我当前正在尝试在C#WinForms中运行一个IF语句来检查两个被屏蔽的文本框是否已经完成,在那种情况下会向用户显示一个按钮。这是我的代码:

if (maskedTextBox1.MaskFull && maskedTextBox2.MaskFull)
{
    button4.Visible = true;
}
else 
{
    button4.Visible = false;
}

When i run my application the buttons visibility is still staying hidden even when my Masked Textboxes have been completed/fully filled in. Does anyone know why this is occurring?

当我运行我的应用程序时,即使我的蒙面文本框已经完成/完全填充,按钮可见性仍然保持隐藏。有人知道为什么会发生这种情况吗?

1 个解决方案

#1


First, you condition can be a lot shorter: button4.Visible = (maskedTextBox1.MaskFull && maskedTextBox2.MaskFull);.
Second, are you sure you need MaskFull and not MaskCompleted?

首先,你的条件可以短得多:button4.Visible =(maskedTextBox1.MaskFull && maskedTextBox2.MaskFull);.其次,你确定你需要MaskFull而不是MaskCompleted吗?

#1


First, you condition can be a lot shorter: button4.Visible = (maskedTextBox1.MaskFull && maskedTextBox2.MaskFull);.
Second, are you sure you need MaskFull and not MaskCompleted?

首先,你的条件可以短得多:button4.Visible =(maskedTextBox1.MaskFull && maskedTextBox2.MaskFull);.其次,你确定你需要MaskFull而不是MaskCompleted吗?