giving focus to another textbox

3 posts, 1 answers
  1. Tendai
    Tendai avatar
    4 posts
    Member since:
    Feb 2012

    Posted 08 May 2012 Link to this post

    I am entering avalues into another text box and I want it to surrender Focus to another textbox if the value I have entered is the same as the one in the database.However what is happening is that  if the value is the same as in the database the cursor just disappears and it does not give focus to the control that I want it to give focus to. Any ideas on how I can correct this.

    Private Sub txtProducedAt_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtProducedAt.TextChanged
     
            Dim iSql As String = "SELECT ID,SiteName   FROM  Sites WHERE SiteName = '" & txtProducedAt.Text & "'     "
            Dim da As New OleDbDataAdapter(iSql, LoginForm1.Conn)
            Dim dTable As DataTable = New DataTable
            da.Fill(dTable)
            If dTable.Rows.Count = 0 Then
     
                Exit Sub
     
            ElseIf dTable.Rows.Count > 0 Then
     
                txtProducedAt.Text = dTable.Rows(0)("SiteName").ToString
     
                txtAccountNumber.Focus()
     
            End If
     
        End Sub
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 May 2012 Link to this post

    Hello, 

    To focus on the textbox, you will need to focus on the textbox element of the control. E.g. 
    Me.RadTextBox1.TextBoxElement.Focus()

    You can see more about the textbox control element structure here
    Thanks
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 11 May 2012 Link to this post

    Hello,

    I am marking Richard's post as answer, since this is the right way to go.
     
    Greetings,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top