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;
            }
        }
C#.NET Programming

Avatar of undefined
Last Comment
finance_teacher

8/22/2022 - Mon
Brendan M

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

ASKER
That also fails, keeping focus in the original control.
gery128

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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
gery128

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
finance_teacher

ASKER
Both of the above failed, e.Cancel ran, but kept focus on the current control.