In vb.net i have one panel in which multiple picture box controls are added. When a double click is made on picture box, I want to save image of it. so how to know on which picture box control in panel double click is done?
Asked
Active
Viewed 1,221 times
2 Answers
2
You can handle the DoubleClick event of each picture box. The DoubleClick eventhandler has a Sender parameter which holds the reference to the actual control that raised the event.

Rhapsody
- 6,017
- 2
- 31
- 49
-
So if there are 20 picture boxes i will have to write two subroutines? So is there any other way by which this can be done by writing single subroutine? – vaichidrewar Apr 09 '11 at 19:54
-
@vaichidrewar, you need to use handle multiple controls with comma separated control names, also you can check my answer on similar line of @Rhapsody – indiPy Apr 09 '11 at 19:58
2
Private Sub Button2_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Pic1.DoubleClick,Pic2.DoubleClick, anyothercontrol.DoubleClick
//(cast sender to picture control)
If TypeOf sender Is PictureControl Then
ControlName = DirectCast(sender, PictureBox).Name //use select case for further programming with control
Else
ControlName = DirectCast(sender, someothercontrol).Name
End If
End Sub

indiPy
- 7,844
- 3
- 28
- 39