且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将点击事件添加到Picturebox vb.net

更新时间:2023-12-06 16:49:52

使用AddHandler语句订阅Click事件:

Use the AddHandler statement to subscribe to the Click event:

    AddHandler pic.Click, AddressOf pic_Click

pic_Click()方法的sender参数为您提供了对图片框的引用:

The sender argument of the pic_Click() method gives you a reference to the picture box back:

Private Sub pic_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim pic As PictureBox = DirectCast(sender, PictureBox)
    ' etc...
End Sub

如果您需要有关特定控件的其他信息(例如索引),则可以使用Tag属性.

If you need additional info about the specific control, like an index, then you can use the Tag property.