toesieo
7/30/2013 - 2:13 PM

Let the user press Ctrl-A to select all of the text in a TextBox in VB .NET When the TextBox's KeyPress event sees the Ctrl-A key code (1),

Let the user press Ctrl-A to select all of the text in a TextBox in VB .NET When the TextBox's KeyPress event sees the Ctrl-A key code (1), it casts the event's sender into a TextBox and calls the TextBox's SelectAll method. The code then sets e.Handled to True to indicate that the character has been handled. This prevents the TextBox from beeping.

If e.KeyChar = Convert.ToChar(1) Then
        DirectCast(sender, TextBox).SelectAll()
        e.Handled = True
    End If