I have a panel on a form, with the panel's AutoScroll property set to True.
On that panel I have placed several GroupBox controls, which take up more space than the panel does - thus, the panel sprouts a vertical scroll bar.
One of the panels can change height at runtime if need be (I programmatically set its height based on the amount of text it contains):
groupBox1.Height = label1.Height + label1.Top + 10;
This works fine if the panel increases in height - the GroupBoxes below it "move down." However, if the panel decreases in height, the GroupBoxes below do not "move up."
I know I can move the groupbox controls that are below upwards programmatically, but I'm thinking there must be a better/less fussy way of doing it than that...
Replace the Panel
with a FlowLayoutPanel
instead and this will become automatic.
(you might want to turn off the wrapping of the FL-Panel)