Hi Guys,
I have a Winform application where i added picturebox's to a flowlayout panel dynamically from code. I have successfully managed to add a handler for doubleclick and click events the problem i have is that when i add both together it only seems to work with the click event and not the double click. Any ideas where I could bee going wrong? Iam using VS2008 .NET 3.5
Thanks
my code looks a bit like this :
Public Class Class1
Dim WithEvents picturebox1 As PictureBox
Private Sub Brochure_Creator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 to 2
picturebox1 = New PictureBox
picturebox1.Image = System.Drawing.Image.FromFile(myPicArray(i))
picturebox1.Name = "PB" & i
picturebox1.Size = New Size(165, 99)
picturebox1.SizeMode = PictureBoxSizeMode.StretchImage
picturebox1.BorderStyle = BorderStyle.None
picturebox1.BackColor = Color.Black
AddHandler picturebox1.DoubleClick, AddressOf Picturebox1_DoubleClick
AddHandler picturebox1.Click, AddressOf Picturebox1_click
FlowLayoutPanel1.Controls.Add(picturebox)
picturebox = Nothing
End Sub
Private Sub Picturebox1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picturebox1.Click
Msgbox("click")
End Sub
Private Sub Picturebox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picturebox1.DoubleClick
Msgbox("doubleclick")
End Sub
End Class
I have a Winform application where i added picturebox's to a flowlayout panel dynamically from code. I have successfully managed to add a handler for doubleclick and click events the problem i have is that when i add both together it only seems to work with the click event and not the double click. Any ideas where I could bee going wrong? Iam using VS2008 .NET 3.5
Thanks
my code looks a bit like this :
Public Class Class1
Dim WithEvents picturebox1 As PictureBox
Private Sub Brochure_Creator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 to 2
picturebox1 = New PictureBox
picturebox1.Image = System.Drawing.Image.FromFile(myPicArray(i))
picturebox1.Name = "PB" & i
picturebox1.Size = New Size(165, 99)
picturebox1.SizeMode = PictureBoxSizeMode.StretchImage
picturebox1.BorderStyle = BorderStyle.None
picturebox1.BackColor = Color.Black
AddHandler picturebox1.DoubleClick, AddressOf Picturebox1_DoubleClick
AddHandler picturebox1.Click, AddressOf Picturebox1_click
FlowLayoutPanel1.Controls.Add(picturebox)
picturebox = Nothing
End Sub
Private Sub Picturebox1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picturebox1.Click
Msgbox("click")
End Sub
Private Sub Picturebox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picturebox1.DoubleClick
Msgbox("doubleclick")
End Sub
End Class
Last edited: