3 Replies - 619 Views - Last Post: 12 November 2016 - 09:59 AM Rate Topic: -----

#1 Philip.ganaban   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-November 16

Stop light with text box and tab key to run through

Posted 11 November 2016 - 04:01 PM

REM Turn this text box green and the others gray
5: TextBox1.BackColor = Color.Green
6: TextBox2.BackColor = Color.Gray
7: TextBox3.BackColor = Color.Gray


I already set my tab order but I can't figure out how to change the text box to the proper color when I hit my Tab key.
Is This A Good Question/Topic? 0
  • +

Replies To: Stop light with text box and tab key to run through

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15160
  • View blog
  • Posts: 60,694
  • Joined: 12-June 08

Re: Stop light with text box and tab key to run through

Posted 11 November 2016 - 05:38 PM

Would that be a focusing enter event?
Was This Post Helpful? 0
  • +
  • -

#3 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1536
  • View blog
  • Posts: 3,864
  • Joined: 01-February 13

Re: Stop light with text box and tab key to run through

Posted 12 November 2016 - 05:06 AM

Look into using the TextBox`s Enter Event.
Public Class Form1
    Private Sub TextBox1_Enter(sender As Object, e As EventArgs) Handles TextBox1.Enter
        'change the BackColor of the 3 TextBoxes
    End Sub

    Private Sub TextBox2_Enter(sender As Object, e As EventArgs) Handles TextBox2.Enter
        'change the BackColor of the 3 TextBoxes
    End Sub

    Private Sub TextBox3_Enter(sender As Object, e As EventArgs) Handles TextBox3.Enter
        'change the BackColor of the 3 TextBoxes
    End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6805
  • View blog
  • Posts: 28,134
  • Joined: 12-December 12

Re: Stop light with text box and tab key to run through

Posted 12 November 2016 - 09:59 AM

It is also possible to use a single handler:

    Private Sub TextBox3_Enter(sender As Object, e As EventArgs) _ 
        Handles TextBox3.Enter, TextBox2.Enter, TextBox1.Enter

    End Sub

using sender to discover which particular box was entered.

To get this code stub use the shift key to select the three controls, then go to the Properties Window, find the Enter event, and double-click it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1