|
-
Jul 21st, 2011, 03:55 AM
#1
Thread Starter
Lively Member
[RESOLVED] Clickable picture box in flowlayoutpanel
Hi,
Quick question... I know I'm lame, but please help me.
Got this code (I bolded the part that causes a problem):
Code:
Public Class Form5
Dim TheFilePath As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
TheFilePath = fbd.SelectedPath
Try
For Each F As String In System.IO.Directory.GetFiles(fbd.SelectedPath)
Dim NewImage As Image = Image.FromFile(F)
NewImage = NewImage.GetThumbnailImage(NewImage.Width * 0.5, NewImage.Height * 0.5, AddressOf abort, System.IntPtr.Zero)
Dim P As New PictureBox
P.SizeMode = PictureBoxSizeMode.AutoSize
P.Image = NewImage
AddHandler P.Click, AddressOf PictureBox_Click
FlowLayoutPanel1.Controls.Add(P)
ListBox1.Items.Add(System.IO.Path.GetFileName(F))
Next
Catch ex As Exception
End Try
End If
End Sub
Private Function abort() As Boolean
Return False
End Function
Private Sub PictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'code for picturebox click
'WHAT DO I ADD HERE TO OPEN THE CLICKED IMAGE?
End Sub
End Class
This has to be easy, but I can't figure out how to make those pictureboxes in flowlayoutpanel clickable. Any example will do - opening it in default picture browser, using it as panel background or using it as a picture for separate picturebox - anything will do - I simply do not know how to get the file name assiciated with the particular picturebox in the flowlayoutpanel.
Please help me do it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|