|
-
Jun 5th, 2005, 11:47 AM
#1
Thread Starter
Hyperactive Member
Button Help[resolved]
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
Last edited by imadthemad; Jun 6th, 2005 at 12:11 PM.
-
Jun 5th, 2005, 11:53 AM
#2
Re: Button Help
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 5th, 2005, 01:02 PM
#3
Thread Starter
Hyperactive Member
Re: Button Help
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...
-
Jun 5th, 2005, 01:03 PM
#4
Addicted Member
Re: Button Help
I listed all my buttons. How to change the color now?
It has been said that something as
small as the flutter of a butterfly's
wing can ultimately cause a typhoon
halfway around the world...

-
Jun 5th, 2005, 01:05 PM
#5
Re: Button Help
You need to convert the sender object so you can determine which control to manipulate.
VB Code:
CType(sender, Button).BackColor = Color.LightGoldenrodYellow
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 5th, 2005, 01:10 PM
#6
Addicted Member
It has been said that something as
small as the flutter of a butterfly's
wing can ultimately cause a typhoon
halfway around the world...

-
Jun 5th, 2005, 01:11 PM
#7
Re: Button Help
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 6th, 2005, 04:32 AM
#8
Thread Starter
Hyperactive Member
Re: Button Help
Excellent code
thanx billions that saves alot of time
now i know what the sender object is for
TY
-
Jun 6th, 2005, 10:40 AM
#9
Re: Button Help
Glad you got it working now. 
Ps, dont forget to 'Resolve' your thread so others will know its solved.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|