Ejemplo de FlowLayoutPanel
Este controles muy util para tener bien ordenados ciertos controles, en este ejemplo vamos a ordenar varios botones al estilo de onedrive.
te recomiendo que veas el video no obstante necesitas
1 layoutpanel y 2 checkbox.
aqui te dejo el codigo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim dinfo As New IO.DirectoryInfo("C:\3d") For Each Finfo As IO.FileInfo In dinfo.GetFiles Dim C As New Button C.TextAlign = ContentAlignment.BottomLeft C.Font = New System.Drawing.Font("Segoe UI", 9) C.ForeColor = Color.White C.Text = Finfo.Name C.Name = Finfo.Name C.BackColor = Color.Blue C.Size = New System.Drawing.Size(117, 65) C.FlatStyle = FlatStyle.Flat AddHandler C.Click, AddressOf Button1_Click Try Dim TH As Image = Image.FromFile(Finfo.FullName) C.Image = TH.GetThumbnailImage(72, 72, Nothing, IntPtr.Zero) Catch ex As Exception End Try FlowLayoutPanel1.Controls.Add(C) Next End Sub Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged FlowLayoutPanel1.WrapContents = CheckBox2.Checked End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged FlowLayoutPanel1.AutoScroll = CheckBox1.Checked End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) 'Handles Button1.Click MsgBox(sender.text) End Sub End Class |
Y aqui el video.
Espero que te sirva, y registrate y comenta.