How can I make some space between labels both across and down in a FlowLayoutPanel

Devon Nullman 20 Reputation points
2024-12-05T02:38:06.26+00:00

Sample for reference onlyI have tried changing the margin and padding, but it changes nothing. there seems to always be a perfect space left-to-right but top to bottom the labels touch each other.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,760 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 32,961 Reputation points Microsoft Vendor
    2024-12-05T10:39:25.8933333+00:00

    Hi @Devon Nullman ,

    You need to adjust the Margin property of the labels.

    For example:

    For i As Integer = 1 To 20
        Dim label As New Label()
        label.Text = "Label " & i
        label.Size = New Size(50, 30)
        label.Margin = New Padding(5) ' Space around each label
        label.BorderStyle = BorderStyle.FixedSingle
        flowPanel.Controls.Add(label)
    Next
    
    

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.