By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Control.Leave vs Control.LostFocus

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.