Determining which control in an array has been clicked

vbnetgib

New member
Joined
Apr 17, 2005
Messages
2
Programming Experience
5-10
I have created an array of picture boxes and set an AddHandler to the array

eg AddHandler PictureBox(i).Click, AddressOf PictureBox_Click

However, I want to be able to determine which picture box within the array has been called. For example, if it is the first control in the array is clicked it will do one thing, if the second is called another thing, etc.

Any one know any way round this? Thanks
 
VB.NET:
Dim PictureBox as Picturebox = CType(Sender, Pictrebox)
Select Case PictureBox.Name
Case "Name1"
Case "Name2"
'etc...
End Select
 
hmmmmmm

hmm, thanks :) but how do I do this with an array?

Dim
PictureBoxes(10) As PictureBox = CType(Sender, PictureBox)

brings up this error:
"Explicit initialization is not permitted for arrays declared with explicit bounds".

If I enter this code:
Dim
PictureBoxes(i) as New PictureBox = (Sender, PictureBox)

when the picture boxes is being creater, it says 'End of statement expected' at the = sign.


hmmmmmmmm


 
oh from an array, umm i have no clue but if you have multiple picturebox's on a form and you have one sub for all of them IE Multiple Handles then you'd use sender to determine which picturebox it is
 
Back
Top