C# MaskedTextBox -- ignore BLANK text ?

How can I change the below so when users remove a date from the below TEXTBOX and click "TAB" it goes to the next control ?

Currently FOCUS remains on the current control and their only option is to enter a bogus date like 09/09/2099.

        private void dATE_DISTRUBUTEDMaskedTextBox_Validating(object sender, CancelEventArgs e)
        {
            if (dATE_DISTRUBUTEDMaskedTextBox.Text == "  /  /")
            {
                e.Cancel = true;
            }
        }
finance_teacherAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
gery128Connect With a Mentor Commented:
Can you try this? this will allow blank/empty date input (e.g. textbox with no date but mask only)
  private void dATE_DISTRUBUTEDMaskedTextBox_Validating(object sender, CancelEventArgs e)
        {
            if (dATE_DISTRUBUTEDMaskedTextBox.Text == "  /  /")
            {
                e.Cancel = false;
            }
        }

Open in new window

0
 
brendanmeyerCommented:
try <nextcontrol>.Focus();
<nextcontrol> being the name of the next control eg: textbox2
0
 
finance_teacherAuthor Commented:
That also fails, keeping focus in the original control.
0
 
gery128Commented:
According to following link, you can use this property of MaskedTextBox to go ahead with blank space:

dATE_DISTRUBUTEDMaskedTextBox.ResetOnSpace = false;

http://stackoverflow.com/questions/8334838/can-a-winforms-maskedtextbox-allow-spaces
0
 
finance_teacherAuthor Commented:
Both of the above failed, e.Cancel ran, but kept focus on the current control.
0
All Courses

From novice to tech pro — start learning today.