How to stretch the inner panel in the form of windows in full screen mode?

I have a windows application that runs in full screen and there are several panels in my form that I want them to stretch in width, I mean, how can I add width = 100% to this panel?

As shown in the figure below, the right panel is my inner (container panel), which should be stretched, it contains many elements: 2 panels, a toolbar and a grid. I just set Doc = "Fill" and Anchor = "top, right, left, bottom", but nothing has changed.

enter image description here

+4
source share
2 answers

To stretch the panel to the entire form, change the Anchor property of the panel control and set it for all four of them. Resize the control to stretch it to fit the entire shape.

 panel1.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left; 

Secondly, to create a form in full screen mode:

 this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; 
+7
source

In Windows Forms, there are two ways to create the size of a control using a form: the Dock and Anchor properties:

enter image description hereenter image description here

Docking gives you the ability to control around the edges of the form and central control. Anchor allows you to specify that the control should always have the same distance from a given set of edges. If you include both the left and right edges, then the size will change in width when the shape is resized.

+3
source

All Articles