Results 1 to 2 of 2

Thread: [RESOLVED] Obtaining Events for All Pictureboxes in the FlowLayoutPanel1

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Resolved [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:
    1. Public Class Form1
    2.     Dim WithEvents p As New PictureBox
    3.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    4.  
    5.         FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
    6.  
    7.         p.ImageLocation = "E:\testScan\temp\1.tif"
    8.         p.SizeMode = PictureBoxSizeMode.Zoom
    9.         p.AllowDrop = True
    10.         FlowLayoutPanel1.Controls.Add(p)
    11.         p = New PictureBox
    12.         p.ImageLocation = "E:\testScan\temp\2.tif"
    13.         p.SizeMode = PictureBoxSizeMode.Zoom
    14.         p.AllowDrop = True
    15.         FlowLayoutPanel1.Controls.Add(p)
    16.         p = New PictureBox
    17.         p.ImageLocation = "E:\testScan\temp\3.tif"
    18.         p.SizeMode = PictureBoxSizeMode.Zoom
    19.         p.AllowDrop = True
    20.         FlowLayoutPanel1.Controls.Add(p)
    21.     End Sub
    22.  
    23.     Private Sub p_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles p.MouseEnter
    24.  
    25.     End Sub
    26. End Class

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Re: Obtaining Events for All Pictureboxes in the FlowLayoutPanel1

    VB Code:
    1. Public Class Form1
    2.     Dim WithEvents p As New PictureBox
    3.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    4.  
    5.         FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
    6.         AddHandler p.MouseEnter, AddressOf p_MouseEnter
    7.         p.ImageLocation = "E:\testScan\temp\1.tif"
    8.         p.SizeMode = PictureBoxSizeMode.Zoom
    9.         p.AllowDrop = True
    10.         FlowLayoutPanel1.Controls.Add(p)
    11.         p = New PictureBox
    12.         AddHandler p.MouseEnter, AddressOf p_MouseEnter
    13.         p.ImageLocation = "E:\testScan\temp\2.tif"
    14.         p.SizeMode = PictureBoxSizeMode.Zoom
    15.         p.AllowDrop = True
    16.         FlowLayoutPanel1.Controls.Add(p)
    17.         p = New PictureBox
    18.         AddHandler p.MouseEnter, AddressOf p_MouseEnter
    19.         p.ImageLocation = "E:\testScan\temp\3.tif"
    20.         p.SizeMode = PictureBoxSizeMode.Zoom
    21.         p.AllowDrop = True
    22.         FlowLayoutPanel1.Controls.Add(p)
    23.     End Sub
    24.  
    25.     Private Sub p_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
    26.         Debug.Print(sender.imagelocation.ToString)
    27.     End Sub
    28. End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width