How can I determine if a radio button is clicked during a MaskedTextBox validated event?
Posted on 2013-06-21
I have two radio buttons, ID One and ID Two. I have two MaskedTextBoxes, ID One and ID Two. The user can choose to enter an ID for either one of the MaskedTextBoxes. These are two different types of IDs. Each can be used to enter a person's ID to pull a record. Some users will want to use ID One type and some users will want to use ID Two type. During the respective MaskedTextBox's Validated event, the app searches for the entered ID and, if valid, populates the other fields on the screen accordingly. If a user selects ID One radio button, the form clears, the ID One Masked Text Box is enabled and becomes the active control; and, the ID Two MaskedTextBox is disabled. If a user selects ID Two radio button, the form clears, and the reverse occurs. Here's the problem:
When a radio button is selected (while active control is the enabled MaskedTextBox), the Validate event of the current active control fires. At this point, I really don't want to validate the active MaskedTextBox, as I am just clearing and trying to reset the form and change to enable the other MaskedTextBox. I tried to used the radiobutton's Checked property, but, at this point in the process, the status hasn't changed yet. It does not change until some time after the Validated event is finished.
How do I control the Validated event to only execute code when the Validated event is NOT triggered by changing the radio button selection?