how to stretch inner panel in windows form on full screen mode?

Matt Stone picture Matt Stone · Jul 30, 2012 · Viewed 13.1k times · Source

I have a windows application that run in full screen and there are some panels inside my form which I want they stretch in width, I mean how i can add width=100% to these panel?

As you see in the below image, right panel is my inner one(container panel) that should stretch, it contains many items: 2 panels, toolstrip and a grid. I just set the Doc="Fill" and Anchor="top; right; left; bottom" to it but nothing changed.

enter image description here

Answer

M. Ahmad Zafar picture M. Ahmad Zafar · Jul 30, 2012

To make the panel stretch to the whole of the form change the Anchor property of the panel control and set it to all four of them. Resize the control to stretch to the whole of the form.

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

Secondly for making a form fullscreen:

this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;