Click here to Skip to main content
15,071,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I managed to arranged few forms to be located on 1 window form inside each panel for each forms. What I'm having problem is whenever I want to maximize the winform inside the panel to full screen, it only maximize to the panel not pc screen. Code below shows how I view the winform into the panel.

panel1.Dock = DockStyle.Fill; <------ this code somehow work to maximize it but why the form located behind instead of floating on top

What I have tried:

con = new MySqlConnection(cs);

Centile_Chart centile = new Centile_Chart();
centile.TopLevel = false;
panel1.Dock = DockStyle.Fill;
Updated 16-Nov-20 23:35pm
Richard MacCutchan 17-Nov-20 5:43am
As far as I know controls inside a panel cannot expand beyond the limits of the panel.
Nrl Syfiqah 17-Nov-20 6:00am
Seems it like that, or should I just put all the forms at fixed position of a parent form with default size instead put all forms inside panel?
Richard MacCutchan 17-Nov-20 6:06am
The only form that you can maximise is the main form that has no parent; which means that the Desktop is effectively its parent. If you want to maximise a form to the entire screen then it must be a freestanding one.
Nrl Syfiqah 17-Nov-20 6:27am
the closest answer i get is using
1)form.Dock = DockStyle.Fill; <------this one only maximize to full panel
2)panel.Dock = DockStyle.Fill; <-----this one able to fill the dock of parent but it located behind other text/form
Richard MacCutchan 17-Nov-20 6:49am
Yes, for the reasons I have already explained. You need to understand how Windows and Windows Forms actually work. Every window is a child of some other window. The ones that are on the Desktop (usually main forms) can expand to fill the screen. The ones that are children of other windows can only expand to fill their parent control, main form, panel, dialog etc.
Nrl Syfiqah 17-Nov-20 12:33pm
how to expand the child form to their parent control? so it able to maximize to fill parent control. mine when i click child form to maximize, it located at the back of other forms on parent
Richard MacCutchan 17-Nov-20 12:37pm
Then you must be doing something wrong. But there is no way anyone here can guess what that may be.

1 solution

Try this:
centile.TopMost = true;
centile.TopLevel = false;
centile.Dock = DockStyle.Fill;
Nrl Syfiqah 17-Nov-20 5:45am
centile.Dock = DockStyle.Fill;

when i use this, it only enlarge max to the size of panel instead of full screen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900