Saturday, May 21, 2011

Visual Basic code: Enabling Select All function in TextBox

For VB developers:

If you're using System.Windows.Form.Text, you might notice that press Ctrl+A does not enable the select all function to select all text in the text box. This function needs to be coded:

Object, ByVal _
    e As System.Windows.Forms.KeyPressEventArgs) Handles _
    TextBox2.KeyPress
    If e.KeyChar = Convert.ToChar(1) Then
        DirectCast(sender, TextBox).SelectAll()
        e.Handled = True
    End If
End Sub

No comments:

Post a Comment