How to grow all controls within form - vb.net

I'm having difficulty with resizing controls in two panels...
I have a form with two panels stacked on top of each other. The top panel takes up 38% of the form and the bottom panel takes up 58% of the form and a 4% gap between.I have a tab control in one and group box in the other.
I've been trying to perform fills/docks within the panels that will cause all controls to grow and shrink with the panel's size. In other words I'm trying to keep the same space and size percents for all controls based on the form size. Visual studios keeps crashing when trying different fills/docks and I don't want to calculate size percents and x/y coordinates for each control. Is there a way to set up the fill within the panel or container so that it looks almost the same at most sizes?

In my experience, docking causes more problems than it helps. What I do instead, is undock the controls and then anchor them on all sides. Then I size them within the panel how I want them. Then, if the panel is ever resized, the controls anchored within them will resize accordingly and it will stay within the boundaries like I want it to. Try that.

Related

Inaccurate Form size

I am trying to create a form with a 500 x 500 form size.
Then I create a panel with a 500 x 500 size.
Logically, the panel size would be the same as the form size.
However, the panel turns out to be significantly larger than the form.
This gave me the conclusion that the form size turns much smaller than the given size which is 500 x 500.
How do I make the form size have the accurate size instead of having it smaller than the given size (e.g. 500 x 500)?
Here is a video that I’ve made to give you guys a clear picture of my problem.
https://youtu.be/RwN2ZpdPMus
The form size refers to the outer edge. The form has a resize border all around it plus a title bar where you cannot place controls. The remaining part inside is the ClientRectangle. You can get its size through
frm.ClientRectangle.Size
' or inside the form itself
ClientRectangle.Size
If you set your panels Dock property to DockStyle.Fill, it will automatically fill up the whole available space. You can do so in the designer in the properties window through a graphical input or in code. The Size property, in this case, is irrelevant.
If you add serveral docked controls, the sequence matters. The fist ones will occupy the outer edges, if docked to some edge.

FlowLayoutPanel bottom inner spacing

So I'm having troubles making my FlowLayoutPanel work the way I want.
When adding multiple controls to it so that vertical scroll appears and when scrolled to bottom I don't want controls to be touching the bottom border of FlowLayoutPanel.
Padding works properly for all but the bottom side, controls are properly spaced away from the edges of the FlowLayoutPanel, I don't know why bottom is special.
I need a solution that does not include adding invisible/transparent controls to it.
The closest I got to what I want was lowering the clientsize by some amount, but then in that area control doesn't repaint so it shows parts of added controls forever.
Kind of fixed with with larger margins on child controls, so I'm closing this.

vb.net unwanted richtextbox resizing

i have two richtextboxes of the exact same size located on my form. However, when I run it, one's height reduces. There are other controls around it so it leaves a weird space. What causes that?
Form in the Design tab
Form once I run it
I've tried constraining the control with the "same height" button, I've created a new richtextbox, but it keeps on happening.
It also depends on computers, on screens with unusual resolutions the box is the correct size.
Thank you
Its because scroll bar coming in picture. In order to uniformly set the positions and sizes of RichtextBoxes use DOCKING or Anchoring properly

Make a responsive form in design view (not programmatically)

I am doing a WinForms program which should have a fully responsive design in a full screen.
I get an approach which works more or less well. It consists into calculate a ratio between display screen and original form size.
Then I apply this ratio to the width, left, height, top properties of each control inside the form.
My doubt is about to use a native way for doing this, since, using anchors, the controls keep their same distances with parent control borders, but I doesn't do proportionally, for instance:
Form with 100x100
Button 20x20 located in (10,10)
If I resized the form to 200x200 (multiply by 2), the best approach I can do in design view is keeping the four anchors to the button, so button size will be 120x120 at the same position (10,10), while what I need is a button with size 40x40, at position (20,20), since form size was multiply by 2.
Is it possible with winforms native operations in design view? (Avoiding to make calculations)
Yes it is possible.
Using the Property Dock = Fill you can ask for a component to take all the room in its container.
Now using a TableLayoutPanel, you can define cells to put your components in. And giving cell a percentage size, you can make sure the sizes will change when the form is resized...
Here are more information on these things :
Dock Property
TableLayoutPanel Class
TableLayoutPanel Tutorial

Controls change place and form size changes

I have designed a form in VB.NET. At design time I have placed two buttons on it.
When I run it, the form size looks smaller and the buttons I have placed at the bottom are not visible. Also the alignment of the text and picture box is also different from what I set at design time.
Computer at which I am running the form is using a different resolution.
change the properties (F4) of the buttons: in ANCHOR put Bottom, Right
your buttons will be tied to the bottom and the right of the screen, instead of to the top, left, which is the default.
Grab the screen size at runtime with
Dim screen as System.Windows.Forms.Screen = System.Windows.Forms.Screen.PrimaryScreen
and using a scale factor depending on the current size (in design), scale the window to match. Check the coordinates of the buttons by hand to make sure they are not outside of the visible portion of the window.
You may not have to leave this feature in if you can debug it to the point that you know the exact resolution that you need.