Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change backgound on mouseover

Status
Not open for further replies.

JaeBrett

Programmer
May 5, 2003
196
CN
I want my label to change the background color on mouseover, does anyone have the code for that?


Thanks
 
I don't think that you can change the color of a label. You can change the control's backcolor this way:

Private Sub Record_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.TextBox.Backcolor = 12775
End Sub

However, you can put another label on top of your original label, set it to not visible and change its backcolor to what you want, and do some code like this:

Private Sub Record_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Visible True
Me.Label2.Visible False
End Sub

HTH,

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
The labels have a MouseMove event instead of a MouseOver.

Private Sub YourLabel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
YourLabel.BackColor = lngRed
End Sub
 
Hi,

So if I go with two label, on MouseMove for one, I make Label2 visible and Label1 not visible. So how do I get Label1 visible again? :) If I do MouseMove on Label2, then I have a repetitive motion.

Thanks guys.
 
You would get the original label back again by using control's "Lost Focus" event:

Ex:

Private Sub Record_LostFocus()
Me.Label1.Visible False
Me.Label2.Visible True
End Sub

If you wanted it to stick for awhile you could use a timer event, or the form's "On current" event... There are many ways to get the original label back - when do you want it to show again?

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top