Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

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;
            }
        }
Avatar of Brendan M
Brendan M
Flag of Australia image

try <nextcontrol>.Focus();
<nextcontrol> being the name of the next control eg: textbox2
Avatar of finance_teacher
finance_teacher

ASKER

That also fails, keeping focus in the original control.
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
ASKER CERTIFIED SOLUTION
Avatar of gery128
gery128
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both of the above failed, e.Cancel ran, but kept focus on the current control.