This is a simple, but useful tip. Users of WPF are spoiled. They have all sorts of layout options. Those of us still working in WinForms have FlowLayoutPanel and TableLayoutPanel. That’s it. WPF has those and more.
For my current project, I needed a panel to layout controls vertically. The TableLayoutPanel can be awkward to work with, at least for what I need it to. At first glance, the FlowLayoutPanel looks it won’t work, since it produces something like this:
That’s with changing the FlowDirection to TopDown and putting AutoScroll to true.
But what I want is this:
To achieve this layout, merely set all the following properties on a FlowLayoutPanel:
- AutoScroll = True
- FlowDirection = TopDown
- WrapContents = False
et voilà, Instant stack panel.
Ah, brilliant. Thanks.
It looks like AutoSize instead of AutoScroll also works, which allows you to have the “real” version of stack panel, which can then be wrapped inside of *something else* with auto scroll, as well.
Thank you!
Pingback: ¿Cómo emular un StackPanel de WPF en Windows Forms? - c# windows-forms - Preguntas/Respuestas