Hi gokuldas,
In WinForms, by default the tab order follows the order that you added them into the Form.
For controllling the tab order, set the TabIndex value and make sure that the TabIndex property is not negative.
Here i have created an example in which i have added 6 TextBoxes and set the TabIndex for each TextBox.
Then i have set the Enter and Leave event handlers for each TextBoxes.
Code
Inside the TextBox Enter event handler i.e. when TextBox is focused, the Background color will be changed to Yellow.
Inside the TextBox Leave event handler i.e. when TextBox is focused out, the Background color will be changed to Yellow.
C#
private void txt1_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt1_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.White;
}
private void txt2_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt2_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.White;
}
private void txt3_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt3_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.White;
}
private void txt4_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt4_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.White;
}
private void txt5_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt5_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.White;
}
private void txt6_Enter(object sender, EventArgs e)
{
((TextBox)sender).BackColor = Color.Yellow;
}
private void txt6_Leave(object sender, EventArgs e)
{
((TextBox)sender).BackColor= Color.White;
}
VB.Net
Private Sub txt1_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt1.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt1_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt1.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Private Sub txt2_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt2.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt2_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt2.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Private Sub txt3_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt3.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt3_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt3.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Private Sub txt4_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt4.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt4_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt4.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Private Sub txt5_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt5.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt5_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt5.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Private Sub txt6_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles txt6.Enter
CType(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub txt6_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles txt6.Leave
CType(sender, TextBox).BackColor = Color.White
End Sub
Screenshot