1

如何检查 C# 中的屏蔽文本框是否为空,即用户没有输入任何内容?

我的文本框只允许输入 4 个数字。

谢谢

4

2 回答 2

4

您可以检查TextMaskedTextBox 的属性是否nullString.Empty

if (String.IsNullOrEmpty(maskedTextBox1.Text))
{
    //no input
}
于 2013-03-18T16:06:10.380 回答
3

试试这个:

maskedTextBoxInput.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
if (maskedTextBoxInput.Text == "")
{
    ...
}
于 2013-03-18T16:11:21.783 回答