Hi,
In my application, I haev menu items. one of the menu item name is CLOSE. I also have a textbox in my UI. I want to do soem validation on my textbox on lost focus. I am able to do this but I am not able to handle one case. Scenario is like this: When user type value in textbox and then quickly clicks on CLOSE menu item, in that case I don't want my textbox validation to fire.
How to achieve this ?
Need help in validation
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Shweta LodhaRank #31 · 39.8K reputationPosted Mar 16, 2014, 11:54 AM EDT
1) By checking the tab indexes
2) Lost keyboard focus - On LostKeyboardFocus of the TextBox check if the value of property KeyboardFocusChangedEventArgs.NewFocus is equal to CLOSE.
void TextBox_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
if (e.NewFocus == CLOSE)
{
//do not validate
}
//validate textbox value
}
Rukhsaan120 reputationPosted Mar 16, 2014, 12:17 PM EDT