Focus a control of a Windows Form

Shows how to focus a control in a Windows Form.
If you are working with Web forms it is very simple, you just use "WebControl.Focus()" but this does not work for Windows Forms...

// A example event:
private void btnExampleCommand_Click(object sender, EventArgs e)
    // That's all:
    this.ActiveControl = this.SomeControlObject;
    // This line focuses a control
Snippet Details

Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!

Older comments:

Steve March 03, 2011 at 14:43
nawfal February 16, 2011 at 12:57
wow, thanks.. it worked. and no other tips from other sites worked!!
EBs December 09, 2010 at 09:20
Who told u that the above is not applicable to windows form?
Eric November 17, 2010 at 20:27

you saved my day.

Riven October 27, 2009 at 23:10
Brilliant! I was begging to believe MS was getting logical. Thanks for the reality check.
Andreas August 27, 2009 at 13:13
Thanks!!!! This was the informtion i need. Fast & Short .
Markus March 11, 2009 at 18:13
Thanks! Was helpful for me.
Angel June 26, 2008 at 18:25
Thanks for help, this info is very cool, Just that I need!!