Where is GetFocus()?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the .NET equivalent to the Win32 API function GetFocus()?

I'm currently iterating the controls on my form and testing Focused. I've
been hunting around for hours trying to find where they stuck GetFocus.
 
To set the focus:
Every System.Windows.Forms.Control has a Focus() method, thus since TextBox
is ultimately derived from Control you can call Focus() on your TextBox to
set the focus to your TextBox.

To see if a control has got the focus:
Every Control has a boolean property named Focused that you can check to see
whether or not your control is Focused. This property calls the Win32 API
function GetFocus() behind the scenes.

Gabriel Lozano-Morán
The .NET Aficionado
http://www.pointerx.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top