如何知道在vb.net中双击面板中的哪个控件

发布于 2024-10-31 09:00:37 字数 78 浏览 7 评论 0原文

在 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是我以为 2024-11-07 09:00:37
   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
   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
盛夏已如深秋| 2024-11-07 09:00:37

您可以处理每个图片框的 DoubleClick 事件。 DoubleClick 事件处理程序有一个 Sender 参数,该参数保存对引发事件的实际控件的引用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文