Is the “return” necessary in the code below:
if (((e.KeyChar == '1') && (String.IsNullOrWhiteSpace(textBoxPterodactylNum1.Text))) ||
((e.KeyChar == '2') && (String.IsNullOrWhiteSpace(textBoxPterodactylNum2.Text))) ||
((e.KeyChar == '3') && (String.IsNullOrWhiteSpace(textBoxPterodactylNum3.Text)))) {
e.Handled = true;
MessageBox.Show(String.Format(
"There is no corresponding value for {0} in the pterodactyl TextBox above", e.KeyChar));
return;
}
. . .
// other code follows if gauntlet above is passed through safely; don't want to continue if it didn't, though (if handled was set to true)
?
The
Handledproperty does not stop execution of the event in its tracks, it simply tells bubbled events that you’ve handled it and no longer want anything else to process. So, the code below youre.Handled = truecould potentially reverse that to a false state which would allow bubbled events to continue handling the event.