ok i have 30 buttons on a calculator form
i want to make a function so when the mouse is over each button, it changes back color
how can i do that without writing a mousemove or code for each of them?
tx in advance,
imad akel
Printable View
ok i have 30 buttons on a calculator form
i want to make a function so when the mouse is over each button, it changes back color
how can i do that without writing a mousemove or code for each of them?
tx in advance,
imad akel
Place event handlers on the single procedure for all buttons of concern.
VB Code:
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter, _ Button2.MouseEnter, Button3.MouseEnter, Button4.MouseEnter, Button5.MouseEnter 'All buttons listed in the Handles list will run this procedure 'Change backcolor to new color End Sub Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave, _ Button2.MouseEnter, Button3.MouseEnter, Button4.MouseEnter, Button5.MouseEnter 'All buttons listed in the Handles list will run this procedure 'Change backcolor to original color End Sub
prob with that code
when the mouse is over 1 of these buttons, all 30 of them change backcolor....
mayb i am doing something wrong?
alittle more help please...
I listed all my buttons. How to change the color now?
You need to convert the sender object so you can determine which control to manipulate.
VB Code:
CType(sender, Button).BackColor = Color.LightGoldenrodYellow
Thanks!
The Color object can be found in the System.Drawing namespace. ;)
:)VB Code:
'At the top of your class... Imports System.Drawing 'Or dont use the Imports declaration and just type it all out. CType(sender, Button).Backcolor = System.Drawing.Color.LightGoldenrodYellow
Excellent code
thanx billions that saves alot of time
now i know what the sender object is for
TY
Glad you got it working now. :thumb:
Ps, dont forget to 'Resolve' your thread so others will know its solved. ;)