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;
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.
The preferred solution should be the TableLayoutPanel. Handling OnResize
is going to be much more fragile.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With