Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

winforms adjust controls to push up vertically when others are invisible

Tags:

c#

winforms

I've create a c# winforms form,

It has a bunch of labels positioned and a flowlayoutpanel.

on certain occasions i set one of the labels and the flowlayoutpanel to visible =false.

As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were.

Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has. at the moment it is just the size i set it to be in the designer.

please can you help with these 2 issues.

Thanks

like image 531
raklos Avatar asked Feb 17 '12 11:02

raklos


2 Answers

If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest.

Set the top row's SizeType to AutoSize and the bottom row's to 100%.

When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.

like image 168
AVIDeveloper Avatar answered Nov 09 '22 06:11

AVIDeveloper


The TableLayoutPanel does the pushing. Maybe you can use that if there is no better answer in next time.

like image 26
brgerner Avatar answered Nov 09 '22 04:11

brgerner