[RESOLVED] Obtaining Events for All Pictureboxes in the FlowLayoutPanel1
How can I obtain a MouseEnter event for each Picturebox control that I am loading into the FlowLayoutPanel1? The code below only attaches the event to the last control loaded.
Thanks
VB Code:
Public Class Form1
Dim WithEvents p As New PictureBox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
p.ImageLocation = "E:\testScan\temp\1.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
p = New PictureBox
p.ImageLocation = "E:\testScan\temp\2.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
p = New PictureBox
p.ImageLocation = "E:\testScan\temp\3.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
End Sub
Private Sub p_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles p.MouseEnter
End Sub
End Class
Re: Obtaining Events for All Pictureboxes in the FlowLayoutPanel1
VB Code:
Public Class Form1
Dim WithEvents p As New PictureBox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
AddHandler p.MouseEnter, AddressOf p_MouseEnter
p.ImageLocation = "E:\testScan\temp\1.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
p = New PictureBox
AddHandler p.MouseEnter, AddressOf p_MouseEnter
p.ImageLocation = "E:\testScan\temp\2.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
p = New PictureBox
AddHandler p.MouseEnter, AddressOf p_MouseEnter
p.ImageLocation = "E:\testScan\temp\3.tif"
p.SizeMode = PictureBoxSizeMode.Zoom
p.AllowDrop = True
FlowLayoutPanel1.Controls.Add(p)
End Sub
Private Sub p_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
Debug.Print(sender.imagelocation.ToString)
End Sub
End Class