PC Review


Reply
Thread Tools Rate Thread

Control.Leave vs Control.LostFocus

 
 
vooose
Guest
Posts: n/a
 
      7th Jan 2005
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!
 
Reply With Quote
 
 
 
 
Dan Bass
Guest
Posts: n/a
 
      7th Jan 2005
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" <(E-Mail Removed)> wrote in message
news:On8o%(E-Mail Removed)...
> 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!



 
Reply With Quote
 
Liam McNamara
Guest
Posts: n/a
 
      7th Jan 2005
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" <(E-Mail Removed)> wrote in message
news:On8o%(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gotfocus / lostfocus change control color balu Microsoft Access VBA Modules 2 2nd Jan 2008 07:39 AM
C# 1.1 Windows Control LostFocus GotFocus question Jason Huang Microsoft C# .NET 2 17th Jul 2007 02:26 PM
Query ActiveControl within Datagrid Cell LostFocus event wrong control! Greg Microsoft C# .NET 0 13th Mar 2006 05:40 PM
User Control - GotFocus - LostFocus avinashraj@gmail.com Microsoft Dot NET 1 13th Jan 2006 12:14 AM
LostFocus event of a control dbuchanan Microsoft Dot NET Framework Forms 4 28th Oct 2005 09:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:21 PM.