469,920 Members | 2,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

Control.Leave vs Control.LostFocus

Does anyone know the difference between these two?

The doc for LostFocus says
'Occurs when the control loses focus.'

whereas for Leave it says
'Occurs when the input focus leaves the control'

The doc also states that for controls losing focus you should use Leave,
so I do. Another reason I used it is because comboBox.LostFocus event
was being fired when it gained focus, and then again when it lost focus!
Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
2 20469
When changing with a mouse, the LostFocus occurs, followed by Leave, then
the validation, making them appear almost synonymous.

The difference is when, according to MSDN, changing Focus of a control by
key press, or progmatically. Leave occurs before any validation, and the
LostFocus after. Almost PreLooseFocus as PostLooseFocus type events.

Use Leave on a control, except, as documentation puts it when checking User
Interface Cues:

"This enumeration is used to specify which user interface cues will be
displayed or changed. For example, when the user presses the ALT key, the
keyboard shortcuts on the menu are displayed by underlining the appropriate
character. The bitwise combination of UICues for this example would be
ShowKeyboard and ChangeKeyboard."
"vooose" <no****@microsoft.com> wrote in message
news:On****************@TK2MSFTNGP11.phx.gbl...
Does anyone know the difference between these two?

The doc for LostFocus says
'Occurs when the control loses focus.'

whereas for Leave it says
'Occurs when the input focus leaves the control'

The doc also states that for controls losing focus you should use Leave,
so I do. Another reason I used it is because comboBox.LostFocus event
was being fired when it gained focus, and then again when it lost focus!
Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Hi Vooose,

Well one difference is that when the window the control is on loses focus
the LostFocus event is fired whereas the Leave event is only fired when the
cursor leaves the control.

--Liam.

"vooose" <no****@microsoft.com> wrote in message
news:On****************@TK2MSFTNGP11.phx.gbl...
Does anyone know the difference between these two?

The doc for LostFocus says
'Occurs when the control loses focus.'

whereas for Leave it says
'Occurs when the input focus leaves the control'

The doc also states that for controls losing focus you should use Leave,
so I do. Another reason I used it is because comboBox.LostFocus event
was being fired when it gained focus, and then again when it lost focus!
Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Karuppasamy | last post: by
5 posts views Thread by Dennis C. Drumm | last post: by
4 posts views Thread by Jon Slaughter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.