[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.
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
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 :D