Anchor Auto Scale Size - Overlapping Controls

I'm having problems resizing and scaling window-shaped controls. I set the bindings so that the controls stay in proportion with the form, which works great. However, perhaps I expected too much when I thought that the origin control points would also scale and resize using form scaling, but that is not the case, and I find that my controls overlap. here are some screenshots;

enter image description here

enter image description here

Does anyone know an approach I can take to solve this problem? maybe I need to set the controls to dynamic drawing points that scale, but then these redraw when scaling the form or only when creating?

edit 1: just found this question hidden among the Internet, Problem: the bound controls are overlapping , maybe I need to implement something like this, a resize event.

+4
source share
2 answers

The preferred solution should be a TableLayoutPanel . OnResize will be much more fragile.

+3
source

I wonder if Anchor is really going to scale, it basically binds the sides of the control to the container, and scaling is based on the product of this. E.g. if both left and right sides are fixed, the control will scale in width because the anchor will try to keep the position of the left and right sides intact.

Keeping this in mind, you should think about what you need when the shape is enlarged and you have more space. In the above example, you might want the lbLog list to say that it remains the same size, but the Simulate panel accepts any sapce created. For such a scenario, you must snap the panel to both the left and right sides, while you will only attach the list box to the correct one.

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

+1
source

All Articles