jeudi 9 avril 2015

Size of controls when anchoring/docking is problematic

I'm having some problems with anchoring and resizing stuff in my forms.enter image description here


This (above) is what the control looks like in the first instance when the user's focus is on groupbox1. All good. Notice groupbox2 is anchored on all 4 sides.


enter image description here


Now, when the user's focus shifts to groupbox2 a couple of things happen (above). Groupbox2.Top is then set to be just below groupbox1. Firstly groupbox1 shrinks a bit to only display the most important information. The problem here (I think) is that as soon as groupbox1 shrinks and groupbox2 is shifted upwards dynamically, it doesn't resize to still fill the bottom half of the control, but leaves a silly space just underneath groupbox2. Groupbox2 does still grow correctly when the form is resized, because it is anchored on all 4 sides. However the problem is that silly little unused space beneath groupbox2.


enter image description here


This (above) is what I want to happen. When focus is on groupbox2, it should fill all remaining space underneath groupbox1.


Dock.Bottom doesn't really do the trick, and Dock.Fill covers groupbox1 (which it shouldn't). I can do this by setting the top and height properties dynamically, but have been cautioned several times against using height/width in code.


Any other solutions?


Aucun commentaire:

Enregistrer un commentaire