Tutorials‎ > ‎VB Tutorials‎ > ‎

Set Control Focus at Startup

posted Jan 14, 2010, 8:37 PM by Tim Key   [ updated Jan 14, 2010, 8:38 PM ]

Often times when developing application and using panels, getting a control to receive startup focus can be somewhat of a pain.  After much trial and error and a lot of online research into the problem, I finally found a solution that worked.

In my example I will show you how I overcame this problem using the form load event.


Private Sub Form1(ByVal sender As ObjectByVal e as System.EventArgs) Handles Me.Load


     With Me.Textbox1




     End With


End Sub


The key to this method is to call the focus event then the select event.  I added the SelectAll for my own personal preference.