Answered by:
Problem with order of events

Question
-
I have a tab control where each tab item has a set of text boxes. I have a control flag that is set when these text boxes loose focus. This flag is checked when the tab control selection changes.
The problem is that if I have the focus in a text box and then I change tab, the tab control SelectionChanged event is triggered before the text box LostFocus event.
Isn't it supposed to be the opposite order?
Is there any other way to do this?
Thanks
Thursday, January 29, 2009 8:50 PM
Answers
-
For TextBox you can use the 'TextChanged' event and set your flag at that point. This way you just see if any flags are set just before changing tabs.
I hope this helps.
-noorbakhsh
- Proposed as answer by noorbakhsh Friday, January 30, 2009 9:39 PM
- Marked as answer by Tao Liang Monday, February 2, 2009 1:46 AM
Friday, January 30, 2009 9:39 PM
All replies
-
CGravato said:
Is there any other way to do this?
What are you actually trying to do?
PatricThursday, January 29, 2009 9:11 PM -
Hi,
As patric said what are you trying to do?
The order of the events are just fine. First the tab selection is changed which causes a loss in focus in the TextBox, not the other way around as you have described.
-noorbakhsh
Friday, January 30, 2009 1:02 AM -
Sorry if I didn't explain it well...
I have to set a flag whenever a control, inside a tab item, has its value altered. So that when the user changes tab, it is asked if the user wants to save the changes.
I used a strategy to set that flag at the lost focus event of the controls. But since it's fired after the selection changed it's not working.
I find it intriguing because I have exactly the same behaviour with a list view instead of a tab control and the lost focus is fired before selection changed..
Thanks for helping.
Friday, January 30, 2009 11:57 AM -
For TextBox you can use the 'TextChanged' event and set your flag at that point. This way you just see if any flags are set just before changing tabs.
I hope this helps.
-noorbakhsh
- Proposed as answer by noorbakhsh Friday, January 30, 2009 9:39 PM
- Marked as answer by Tao Liang Monday, February 2, 2009 1:46 AM
Friday, January 30, 2009 9:39 PM