سؤال

How can I check if a masked text box in C# is empty, i.e. the user has not entered anything?

My text box only allows 4 numbers to be input.

Thanks

هل كانت مفيدة؟

المحلول

You can check if Text property of the MaskedTextBox is null or String.Empty

if (String.IsNullOrEmpty(maskedTextBox1.Text))
{
    //no input
}

نصائح أخرى

Try this:

maskedTextBoxInput.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
if (maskedTextBoxInput.Text == "")
{
    ...
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top