Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 875
Matt Stone Avatar asked Jul 30 '12 05:07

Matt Stone


People also ask

How do I make my windows form resizable?

By dragging either the right edge, bottom edge, or the corner, you can resize the form.

How to resize panel in c#?

If you'd like to resize it to a particular size, you can do it on the code behind: Size panelSize = new Size(500, 500); usercontrol1. Parent.

How to set fixed size for form in c#?

Right click on your form and go to properties. Then go to Layout options,see there are a property named Size. Change it as your need as width and length wise.

Is used to set the position of form at run time view?

Remarks. This property enables you to set the starting position of the form when it is displayed at run time. The form's position can be specified manually by setting the Location property or use the default location specified by Windows.


1 Answers

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;
like image 149
M. Ahmad Zafar Avatar answered Oct 19 '22 17:10

M. Ahmad Zafar