Binding Management in Visual Studio 2010

I kind of just get together here, but maybe there is a simple solution that will help me a little time.

When I draw Winforms GUI in the designer, the controls snap to specific points. I can align the source text of one control with another, I can align the left and / or top element of one control with another, etc. This is all great.

What is also great is that the controls are attached to other controls located at a distance from their fields. This means that if I create a vertical array of TextBoxes, then I can have them equidistant in my GUI - it looks less messy.

However, not everything happens correctly or in general. Let's say that I placed my text fields, and now I want to reduce the width of my form so that there are no spaces between the edges of the TextBoxes and the edge of the form. In addition, I want the distance between the edge of the TextBoxes and the edge of the form to be the same on the left, as it is on the right. If I dragged the right edge of the form to the left, then in TextBoxes it will not be anchored. I will have either calculations to determine what width should be, or a juggling action to gradually reduce the width until the TextBox snaps to the left side on the right.

I am not saying that this process is particularly complex or time-consuming. It is simply that if this happened, the whole process would be infinitely easier.

Is there a built-in option in VS2010, or perhaps an extension? Or maybe I'm just doing it wrong in the first place?

+4
source share
2 answers

Removable lines in the designer work great when moving or resizing any of the built-in controls. The only time they do not work is when you resize the form itself.

I agree that it would be very convenient to have a snap here. I would like to know how to do this. But, unfortunately, I do not believe that there is one.

Workarounds - either mathematically calculate the correct size, or guess the size change of the form, and then check your work by dragging one of the controls (and using the latches that appear). I go through the same "juggling act" that you describe, unfortunately, regularly.

+1
source

Whenever the control should be positioned so that it โ€œsnapsโ€ to the edge of the form, I usually first move (or resize) the controls to the desired size, and then change the โ€œAnchorโ€ property of the controls, which should be bound to the corresponding the edge of the form (even if the form itself will not be allowed to resize).

Thus, when I resize the form, the position of the control relative to this form remains the same, simply resizing or moving the control as necessary (depending on the selected snap property).

I completely agree that the ability to โ€œsnapโ€ a form to controls when resizing a form will be extremely useful, but you can usually get around it by using the anchor property this way โ€” times when it doesn't work (for example, when the whole form consists of a column text fields, this is a fixed height), I'm afraid that you need to resort to calculations, but I found that most of my dialogs are mutable.

+1
source

All Articles