1 Replies - 693 Views - Last Post: 15 February 2018 - 09:50 PM Rate Topic: -----

#1 pb12354   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-July 17

Creating a flow layout panel with images and labels?

Posted 15 February 2018 - 03:30 PM

I am filling a FlowLayoutPanel with thumbnail images extracted from ".dwg" files and I am able to label each image with the name of the file it came from using the "lbl" label but I can't figure out how to position the label under the images instead of the default upper right.
Is there a way to do this?
Thanks.

[Private Sub FillLayoutPanel(filepath As String)
FlowLayoutPanel1.Controls.Clear()

Try
Dim viewDwg As New ViewDWG()

For Each foundFile As String In My.Computer.FileSystem.GetFiles(filepath)
Dim imageControl As New PictureBox()
Dim lbl As New Label()
lbl.Location = New Point(10, 15)
imageControl.Height = 125
imageControl.Width = 180
imageControl.BorderStyle = BorderStyle.FixedSingle
Dim sfoundFile As String = System.IO.Path.GetFileName(foundFile)
Dim Ext As String = System.IO.Path.GetExtension(foundFile)
If Ext = ".dwg" Then
fImage = viewDwg.GetDwgImage(foundFile)
ChangeBackGroundToBlack(fImage, bImage)
Thumbs.Add(bImage)
FileNames.Add(sfoundFile)
lbl.Text = sfoundFile.ToString
imageControl.Image = bImage
imageControl.Tag = foundFile
FlowLayoutPanel1.Controls.Add(imageControl)
AddHandler imageControl.Click, AddressOf PictureBox_Click
FlowLayoutPanel1.Controls.Add(lbl)

End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

End Sub]

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a flow layout panel with images and labels?

#2 pb12354   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-July 17

Re: Creating a flow layout panel with images and labels?

Posted 15 February 2018 - 09:50 PM

I have come up with a solution for my own inquiry! I simply defined a new "Panel", a new "PictureBox" and a new Label. I then
added the PictureBox and the Label to the Panel controls.

'  PANEL CREATION
                Dim imagePanel As New Panel
                imagePanel.Width = 180
                imagePanel.Height = 160
                '  PICTUREBOX CREATION
                Dim PicBox As New PictureBox
                PicBox.Width = 185
                PicBox.Height = 120
                PicBox.Location = New Point(14, 15)
                PicBox.BackColor = Color.DarkGray
                imagePanel.Controls.Add(PicBox)
                '  LABEL CREATION
                Dim nameLabel As New Label
                nameLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                nameLabel.Location = New Point(50, 140)
                nameLabel.TextAlign = ContentAlignment.TopLeft
                imagePanel.Controls.Add(nameLabel)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1