"Robert" <an*******@discussions.microsoft.com> wrote in message
news:2e*****************************@phx.gbl...
I have created an array of panels (dim panels(100) as new
panel). I've succesfully loaded them on the form.
What code should I write in order to have acces to the
mouseover event for each of the panels (because I can't
double-click on them and select this event). I want to be
able to control each of the panels' reaction to the
mouseover event by identifying them through an INDEX.
Just like in VB 6.0. :P
You'd use the AddHandler statement to wire up each panel you add to a SINGLE
procedure that you'll supply. Then in the code of that procedure you'll
check the sender argument against your array, like this:
For x = 0 To 100
If sender Is panels(x) Then
' Now you know which panel you have based on x
End If
Next
That's the long way. It would more efficient to set the Tag of each panel
you add and then use that as a key into a HashTable instead of looping
through an array each time. Or, now that I think about it more, just set the
Tag to the index of the panel as you add it and then use the tag to index
into the array. Yeah, that's the ticket....