Select all text in a textbox on enter

cpopham

Junior Contributor
Joined
Feb 18, 2004
Messages
273
I have forgotten how to do this and can not find out information on it to save my life. When my user clicks or tabs into a textbox, I want to select (highlight) all of the text in the textbox so that if they start typing, it delete what is in the textbox and put in what they are typing. Anyone have any ideas?

Chester
 
You'll need to set the textbox to the active control when it is entered either by the mouse or tabed.

Visual Basic:
    Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
    TextBox1.Enter, TextBox1.MouseEnter
        Me.ActiveControl = Me.TextBox1
    End Sub

I think that should get the result you're looking for.
 
Back
Top