Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a windows form application. I have a mainform, formless form and button. the mainform starts in a normal state and when i click on the button on the mainform it opens the formless form called users in a panel on the mainform. The formless form is centered in the main form and when i maximise the mainform the formless form anchor to fill the mainform. This is working correctly but if i maximise the mainform before clicking on the button to open the formless form the formless form does not anchor to fill the main form. I need help on how to fix this so that when i maximise the mainform and click on the button to open the formless form it fill the mainform. This is the code for opening the formless form:

What I have tried:

currentForm = childForm;
childFormContainer.Size = currentForm.Size;
currentForm.TopLevel = false;
childFormContainer.Tag = currentForm;
childFormContainer.Controls.Add(currentForm);
currentForm.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
childFormContainer.Visible = true;
currentForm.Show();
currentForm.BringToFront();
Posted

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