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

giving focus to another textbox

2 Answers 40 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Tendai
Top achievements
Rank 1
Tendai asked on 08 May 2012, 10:34 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 04:20 PM
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
0
Stefan
Telerik team
answered on 11 May 2012, 07:41 AM
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 >>
Tags
TextBox
Asked by
Tendai
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or