Event order sequence...
-
Hi every body , (sorry for my english...) Suppose we have a text box (textBox1). If we "leave" this text box by pressing the TAB key, the order of the following events is: textBox1_Validated textBox1_LostFocus But, if we leave this text box using the mouse, that is by pressing on another control on the Form using the mouse, the order of these events is: textBox1_LostFocus textBox1_Validated This is strange behavior in my opinion. May anyone explain me this behavior? Thanks in advanced, elaj
-
Hi every body , (sorry for my english...) Suppose we have a text box (textBox1). If we "leave" this text box by pressing the TAB key, the order of the following events is: textBox1_Validated textBox1_LostFocus But, if we leave this text box using the mouse, that is by pressing on another control on the Form using the mouse, the order of these events is: textBox1_LostFocus textBox1_Validated This is strange behavior in my opinion. May anyone explain me this behavior? Thanks in advanced, elaj
When you change the focus by using the keyboard, focus events occur in the following order:
- Enter
- GotFocus
- Leave
- Validating
- Validated
- LostFocus
When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:
- Enter
- GotFocus
- LostFocus
- Leave
- Validating
- Validated
There is nothing strange in that, is it? -- modified at 5:22 Monday 22nd January, 2007
SkyWalker
-
When you change the focus by using the keyboard, focus events occur in the following order:
- Enter
- GotFocus
- Leave
- Validating
- Validated
- LostFocus
When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:
- Enter
- GotFocus
- LostFocus
- Leave
- Validating
- Validated
There is nothing strange in that, is it? -- modified at 5:22 Monday 22nd January, 2007
SkyWalker
Hi SkyWalker, There is nothing strange if your code does not depend on it. However, i wrote a code that that register to control's "LostFocus" event and do some job there. If the user call some other method - i unregister the event handler, but it should be done only after the "LostFocus" occurred. Because the the user traditionally will call my method in the "Validate" event, you may understand why this behavior raise some problems. However to overcome it i do the following: I registered to the "GotFocus" event, and within this event handler i registered to the "LostFocus" event. When the "LostFocus" event occurred, i do my job and unregistered the handler when it completed. Elaj
-
Hi SkyWalker, There is nothing strange if your code does not depend on it. However, i wrote a code that that register to control's "LostFocus" event and do some job there. If the user call some other method - i unregister the event handler, but it should be done only after the "LostFocus" occurred. Because the the user traditionally will call my method in the "Validate" event, you may understand why this behavior raise some problems. However to overcome it i do the following: I registered to the "GotFocus" event, and within this event handler i registered to the "LostFocus" event. When the "LostFocus" event occurred, i do my job and unregistered the handler when it completed. Elaj
ok :-)
SkyWalker