Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CTRL + A Hot Key Not Working in Text Box 1

Status
Not open for further replies.

tekrobg

Programmer
Oct 12, 2004
42
US
I am new to programming. The "Select All" hot key (CTRL + A) does not work in any of my text boxes. Do I need to program it to work in a text box? How should I do that?

Thanks for any help.
 
Code:
   Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

        If e.Control = True AndAlso e.KeyCode = Keys.A Then TextBox1.SelectAll()

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        If Microsoft.VisualBasic.AscW(e.KeyChar) = 1 Then e.Handled = True

    End Sub
The first sub do the job. The second is to avoid the beep sound when you press ctrl + a.
 
korach:

Thanks for the help, and thanks for the added tip about the beep - I didn't even think of that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top