1

I have a WinForm with a Panel and I keep adding Labels to it. Is it possible to set the Panel so that everytime I add a label it will have a certain layout ? The layout I am looking for is having a single column of Labels, so everytime I add a new Label it will be added to the next row. I haven't found any property for the Panel to do that. Is this possible ?

dimitris93
  • 4,155
  • 11
  • 50
  • 86
  • Are you adding it manually or programmatically ? – voytek Jun 29 '15 at 16:19
  • @voytek programmatically – dimitris93 Jun 29 '15 at 16:21
  • Change the Y position of the newly created `Label` about `24px` different that one before or use a `Repeater` inside your `Panel` instead. – TestWell Jun 29 '15 at 16:24
  • You can use TableLayoutPanel.you can find a good post [here][1] [1]: http://stackoverflow.com/questions/1142873/winforms-tablelayoutpanel-adding-rows-programatically – mahfuz195 Jun 29 '15 at 16:25
  • you can use TableLayoutPanel.you can find a good post [here][1] [1]: http://stackoverflow.com/questions/1142873/winforms-tablelayoutpanel-adding-rows-programatically – mahfuz195 Jun 29 '15 at 16:27
  • @TestWell This is not a very efficient method, as it will be a mess when adding labels in the begging of the panel for example – dimitris93 Jun 29 '15 at 16:37

3 Answers3

3

Use FlowLayoutPanel instead of Panel. And set the FlowDirection property to TopDown

Yogi
  • 9,174
  • 2
  • 46
  • 61
0

You can create a ListBox in the panel, and then add the Labels to it, rather than to panel directly.

Artak
  • 2,819
  • 20
  • 31
0

Use a TableLayoutPanel and set its ColumnCount to 1.

Erik
  • 5,355
  • 25
  • 39