Hello vb dotnet users,
Via a class we can create pictureboxes and an event. Interesting is to know in the event what is the name or position of the object what caused the event.
Used code:
Public Class PlaatsPictureBox
Private Shared ipb_count As Integer = 0
Public Shared Sub pb(ByVal frm As Form)
Dim npb As New PictureBox
With npb
ipb_count += 1
.Name = "picturebox_" & Str(ipb_count)
.Image = Drawing.Image.FromFile("D:\flow\pictures\join.jpg")
.Size = New Size(52, 52)
.Location = frm.PointToClient(System.Windows.Forms.Form.MousePosition)
AddHandler .MouseDown, AddressOf evt_pb_click
frm.Controls.Add(npb)
.BringToFront()
End With
End Sub
End Class
Module Module1
Public Sub evt_pb_click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
MsgBox(e.Button) 'gives no information
MsgBox(e.Clicks) 'gives no information
MsgBox(e.Delta) 'gives no information
MsgBox(e.X) 'gives no information
MsgBox(sender.GetType.????????????????????????????) 'gives no information
End Sub
End Module
Via a class we can create pictureboxes and an event. Interesting is to know in the event what is the name or position of the object what caused the event.
Used code:
Public Class PlaatsPictureBox
Private Shared ipb_count As Integer = 0
Public Shared Sub pb(ByVal frm As Form)
Dim npb As New PictureBox
With npb
ipb_count += 1
.Name = "picturebox_" & Str(ipb_count)
.Image = Drawing.Image.FromFile("D:\flow\pictures\join.jpg")
.Size = New Size(52, 52)
.Location = frm.PointToClient(System.Windows.Forms.Form.MousePosition)
AddHandler .MouseDown, AddressOf evt_pb_click
frm.Controls.Add(npb)
.BringToFront()
End With
End Sub
End Class
Module Module1
Public Sub evt_pb_click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
MsgBox(e.Button) 'gives no information
MsgBox(e.Clicks) 'gives no information
MsgBox(e.Delta) 'gives no information
MsgBox(e.X) 'gives no information
MsgBox(sender.GetType.????????????????????????????) 'gives no information
End Sub
End Module