I have some code that creates panels with picture boxes in them. I would like something to tell me what picture box was clicked on.
I’m using the following:
PicBx[z].Click += new EventHandler(clicked);
Do I need to assign a value on the click? Or is there a way just to display what you clicked on?
The handler method gets the control that was clicked as its
senderparameter.You can cast it to
PictureBoxand do whatever you want with it.Alternatively, you can add an anonymous method as the handler:
However, make sure not to close over the loop variable.