how to know on which control in panel double click is made in vb.net
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?
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
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.
精彩评论