This is a migrated thread and some comments may be shown as answers.

Selecting all text when a Text Box gets the focus

1 Answer 1788 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 13 Oct 2013, 05:34 AM
Hello,
I am new here hope someone can help me, I been stuck with this for a while and could not figure it out :(

I am using visual studio (VB) Try to make text box and scan serial number, I want after scan then all number will highlight and ready for next scan without using mouse for hit on keyboard to highlight it. but when I used "SelectAll", instead highlight a whole string of number at one time, it highlight single digit and disappear then move to next digit -> highlight and  ....

Private Sub txtTickNum_TextChanged(sender As Object, e As EventArgs) Handles txtTickNum.TextChanged
    Try
        Me.TicketTableAdapter.Serial(Me.TicketDataSet.ticket, CType(txtTickNum.Text, Decimal))
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try
 
    ' Select all text in the text box.
    txtTickNum.SelectAll()
 
 
End Sub
hope some one can help

Thanks

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 15 Oct 2013, 12:57 PM
Hi Jack,

Thank you for contacting Telerik support.

Just calling the SelectAll method will populate the SelectionLength and SelectedText properties, but will not mark the text as you are expecting. In your case to achieve the desired effect you can call the Focus method:
Private Sub radTextBox1_TextChanged(sender As Object, e As EventArgs)
    radTextBox1.Focus()
End Sub

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TextBox
Asked by
Jack
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or