How to make the panel gaps constant width

BenTam 1,621 Reputation points
2022-11-02T09:17:06.99+00:00

Dear All,

I'd like to make the Panel Gaps constant width on resizing the form. Could anyone suggest a way to do it?

256312-panelgap.gif

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 43,046 Reputation points Microsoft Vendor
    2022-11-03T02:43:32.133+00:00

    Hi @BenTam , Welcome to Microsoft Q&A.

    Please use the control's [Margin](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.margin?view=windowsdesktop-6.0#system-windows-forms-control- margin) property.

    Best Regards,
    Jiale


    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.


1 additional answer

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,322 Reputation points Microsoft Employee
    2022-11-03T03:55:34.833+00:00

    If you are working on WinForms, you might put a TableLayoutPanel on the form, and define carefully columns (3 columns with equal length, while a 4th with fixed length), and then drop other controls into the columns so that they can fill up the columns and auto-size to fit in.

    WPF/UWP/WinUI gives you extra flexibility on managing control arrangement with layout tools.