How to Change an object's colour when the mouse pointer is in it ?

Re: How to Change an object's colour when the mouse pointer is in it ? 80 80

You can use the MouseEnter and MouseLeave events as in

Private Sub Button1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles Button1.MouseEnter
    Button1.Tag = Button1.BackColor
    Button1.BackColor = Color.Blue
End Sub

Private Sub Button1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles Button1.MouseLeave
    Button1.BackColor = Button1.Tag
End Sub

In this example I use the Tag property to save the original colour so it can be restored on MouseLeave.

Be a part of the DaniWeb community

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