I have 3 textbox. I want to change Background color when cursor go there, other wise there will be no change.
How can i do this?

My mail address pretom82@hotmail.com

Recommended Answers

All 3 Replies

Try this:

Private Sub ChangeBackcolorRed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.MouseEnter, TextBox2.MouseEnter, TextBox3.MouseEnter
        sender.backcolor = Color.Blue
    End Sub

    Private Sub ChangeBackcolorWhite(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.MouseLeave, TextBox2.MouseLeave, TextBox3.MouseLeave
        sender.backcolor = Color.White
    End Sub

VB.NET Syntax (Toggle Plain Text)
Private Sub ChangeBackcolorRed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Enter, TextBox2.Enter, TextBox3.Enter
sender.backcolor = Color.Blue
End Sub

Private Sub ChangeBackcolorWhite(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave
sender.backcolor = Color.White
End Sub

Hi,

@waynespangler, your code is working with mouseEnter and MouseLeave, but the OP wants to change the backcolor when Tabstop set the focus on the textbox.

@Gopinathv Welkom to the Forum :icon_smile:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.