control.HasFocus()?

  • Thread starter Thread starter Rica
  • Start date Start date
R

Rica

Is there a way to check if a specified control have focus beside
handling LostFocus/GotFocus events ?

I'm pretty sure there was in prev version of VB something like
control.HaveFocus() ...
 
Rica said:
Is there a way to check if a specified control have focus beside
handling LostFocus/GotFocus events ?

Check the control's 'Focused' property.
 
Herfried said:
Check the control's 'Focused' property.
Thanks for your quick answer.

Strangely ,"focused" dont appears in intellisense on any of standart
control I checked (Textbox, panel, listbox, on my own derived control).

But it's in help file.
 
Rica said:
Strangely ,"focused" dont appears in intellisense on any of standart
control I checked (Textbox, panel, listbox, on my own derived control).

I assume that 'Focused' is marked as an advanced member. You can show
advanced members in the code editor with the "Hide advanced members" option
under "Tools" -> "Options" -> "Text Editor" -> "Basic" -> "General".
 
Herfried said:
I assume that 'Focused' is marked as an advanced member. You can show
advanced members in the code editor with the "Hide advanced members" option
under "Tools" -> "Options" -> "Text Editor" -> "Basic" -> "General".

Bingo.

It was the case.

Thanks again for your working answers.
 
Rica,

Exercise caution with composite controls - I have a feeling that this
property is not recursive so if an inner control has focus, the outer one
won't report itself as focused.
 
Back
Top