David ChopperField David ChopperField - 1 year ago 113
C# Question

How to set FlowLayoutPanel contents at Center of Form

I have a few

controls in a
, and I want to set them precisely at middle bottom of
In the image below I set the
precisely at middle by setting the
padding manually by 400 to left.


But when I try to resize or restore down the buttons wont at middle anymore because of manually set of padding.


Is there anything that I can do to set the buttons in middle of
whenever I try to resize it. I'm following the answer base on
this post to add and remove buttons dynamically.

Answer Source

Perform these settings on controls:

  • Add your images to a FolowLyoutPanel
    • Set AutoSize of FolowLyoutPanel to true
    • Set AutoSizeMode of FlowLayoutPanel to GrowAndShrink
    • Set Anchor proprty of FlowLayoutPanel to Top, Bottom
  • Use a TableLayoutPanel for hosting the FlowLayoutPanel
    • Use a single Column and a single Row in TableLayoutPanel.
    • Set Dock property of TableLayoutPanel to Bottom.

This way, when you add or remove images dynamically, all images will be shown at bottom center of the form.