When a Win Forms TextBox control first receives the focus, the default insertion within the text box is to the left of any existing text. The user can move it with the keyboard or the mouse. If the text box loses and then regains the focus, the insertion point will be wherever the user last placed it.
In some cases, this behavior can be disconcerting to the user. In a word processing application, the user might expect new characters to appear after any existing text. In a data entry application, the user might expect new characters to replace any existing entry. The SelectionStart and SelectionLength properties allow you to modify the behavior to suit your purpose.
To control the insertion point in a TextBox control
The code below always returns the insertion point to 0. The TextBox1_GotFocus event handler must be bound to the control; see Creating Event Handlers at Run Time for Win Forms for more information.
[Visual Basic] Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As EventArgs) TextBox1.SelectionStart = 0 TextBox1.SelectionLength = 0 End Sub [C#]
Creating a Password Text Box with the TextBox Control | Creating a Read-Only Text Box | Putting Quotation Marks in a String Programmatically | Selecting Text Programmatically in the TextBox Control | Viewing Multiple Lines in the TextBox Control | TextBox Control