All Things Techie With Huge, Unstructured, Intuitive Leaps

C# .NET Textbox GotFocus Event


When one Googles to find out sample code for a C# .Net textbox gotFocus() event, the first few search results are not that explicit.  So without further ado, here is a sample:

In the Form_Load method:

textBox2.GotFocus += new System.EventHandler(this.textBox2_GotFocus);

And then in the body of the form class you create this method:

private void textBox2_GotFocus(Object sender, EventArgs e)
        {
          //  do something here
        }

Hope this helps someone.

3 comments: