How to check if a MaskedTextBox is empty from a user input?

Muhammed Salah picture Muhammed Salah · Jul 20, 2013 · Viewed 27.6k times · Source

I'm using a MaskedTextBox, with the following short date Mask: "00/00/0000".
My problem is that I wanna know when the control is empty:

if (string.IsNullOrEmpty(maskedTextBox1.Text))
{
    DataTable dt = function.ViewOrders(Functions.GetEid);
    dataGridView2.DataSource = dt;
}

It's not working, when maskedTextBox1 looks empty (and I'm sure it is), the if statement doesn't detect that it is null or Empty.

Answer

Shaharyar picture Shaharyar · Jul 20, 2013

You can simply use:

maskedTextBox1.MaskCompleted

Or

maskedTextBox1.MaskFull

properties to check if user has entered the complete mask input or not.