Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto-scaling size with anchors - overlapping controls

I'm having some trouble with resizing and scaling of controls in a windows form. I've set anchors up so that the controls stay in ratio with the form, which works great. However, perhaps i was expecting too much when i thought that the control origin points would also scale and change with the form scaling, but this is not the case and i'm finding my controls overlapping. here's some screenshots;

enter image description here

enter image description here

anyone know of an approach i can take to solve this problem? perhaps i need to set control origins to dynamic drawing points that scale, but then do these redraw on scaling the form, or only on creation?

edit 1: just found this question hidden amongst the internet, Problem: Anchored controls are overlapping perhaps i need to implement something like this, a resize event.

like image 443
Kestami Avatar asked Oct 08 '22 08:10

Kestami


2 Answers

The preferred solution should be the TableLayoutPanel. Handling OnResize is going to be much more fragile.

like image 73
Jirka Hanika Avatar answered Oct 10 '22 15:10

Jirka Hanika


I wonder if Anchor is really about scaling, it basically anchors the sides of a control to the container and scaling is a by product of this. For eg. if both left & right sides are anchored the control will scale in width because anchor will try to keep the location of left & right sides intact.

keeping that in mind you have to think what do you want when the form is increased in size and you have more space. In the case above you might want the list box lbLog to say remain same size but the panel Simulate take up any sapce created. For such a scenario you would anchor the panel on both left & Right side while you will anchor the list box only the right.

Basically if you want all your controls to proportionally scale (true scaling I would say as opposed to scaling in case of anchoring) then Anchoring is not the right solution.

like image 42
Arif Eqbal Avatar answered Oct 10 '22 13:10

Arif Eqbal