|
-
Mar 8th, 2013, 04:19 PM
#1
Thread Starter
Addicted Member
[RESOLVED] MouseHover event for Multiple Controls?
Hi guys, my problem is this. I need to use the mouseHover event for many controls in my form (100+) to update a label's text when I hover the mouse over any of these controls. My question is, is there any way to create some sort of a "function" that can handle this, so that I don't have to create a sub that handles MyControl.MouseHover for each of my controls that I want to modify it's MouseHover event, but instead have something that works like functions do, and I just type the name of the Control there and The text I want to change the Label to.
If I wasn't clear in my question, tell me.
-
Mar 8th, 2013, 05:30 PM
#2
Re: MouseHover event for Multiple Controls?
vb.net Code:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load For Each ctrl In Me.Controls ' this is the form controls, panels, tabcontrols etc. must be added separately AddHandler CType(ctrl, Control).MouseHover, AddressOf MseHover Next End Sub Private Sub MseHover(sender As System.Object, e As System.EventArgs) Me.Text = "I'm hovering over " & CType(sender, Control).Name End Sub
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Mar 8th, 2013, 06:01 PM
#3
Thread Starter
Addicted Member
Re: MouseHover event for Multiple Controls?
Super Awesome, with a little tweak to the function code I got it going, I was googling AddHandler because I had a feeling it'd be there, I just wasn't finding it.
Thanks dunfiddlin, I really needed this for future reference as well
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
|