Focus a control of a Windows Form

Submitted by:Jhon Smith

Date added:24 August, 2016

Category:C#

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.

Tags: gui , windows forms

Code Snippet:

// A example event:
private void btnExampleCommand_Click(object sender, EventArgs e)
{

// That's all:
this.ActiveControl = this.SomeControlObject;

// This line focuses a control

}
 
 

Comments