Selecting all text when a Text Box gets the focus

2 posts, 0 answers
  1. Jack
    Jack avatar
    1 posts
    Member since:
    Oct 2013

    Posted 13 Oct 2013 Link to this post

    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
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 15 Oct 2013 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top