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 ?
Asked
Active
Viewed 95 times
1

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 Answers
3
Use FlowLayoutPanel
instead of Panel. And set the FlowDirection
property to TopDown

Yogi
- 9,174
- 2
- 46
- 61
-
-
I also had to change the `WrapContents` (last property) to false, so that the scrolling is vertical instead. – dimitris93 Jun 29 '15 at 16:51
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