Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When a child form opens,it opens in maximum size.i want to reduce the size of the childform and fix it in a particular position in a parent form using c#.net(windows application).
Posted
Comments
BillWoodruff 15-Sep-11 7:38am    
Please clarify your question:

1. are you using Windows Forms ?

2. what exactly do you mean by "Child" Form: are you using MDI architecture here, or are you setting the Parent of a Form to another Form directly ?
RoshInd 15-Sep-11 7:46am    
An MdiParent form is there.On buttonclick in an mdiparent form,i have given this code for opening a child form.
panel1.Visible = true;
Lesson Lform = new Lesson(username, password);
Lform.TopLevel = false;
Lform.TopMost = false;
panel1.Controls.Add(Lform);
Lform.Parent = this;
Lform.ShowIcon = true;
Lform.FormBorderStyle = FormBorderStyle.Fixed3D;
Lform.Show();
Lform.BringToFront();
but it opens in full size mode.

Some observations on your code: now that we know you are kind-of mis-using MDI:

1. you are inserting a Form into a Panel: that's not a good idea either using, or not using, MDI architecture.

2. Since you are using MDI, you want to be setting a Form's MDIParent property, not Parent property.

2. Have you tried setting the Form you create's StartPosition property ? Try setting it to 'Manual,' and then define an Event Handler for the new Form's 'Shown' Event in which you do what you need to do position the Form in relation to its container.

And, please read up on MDI, as well as consider not using it: it's been "deprecated," meaning it's not thought of as a good solution to multi-form architecture at this point in time.

best, Bill
 
Share this answer
 
Set the form's Width, Height, and Location properties in the Load event handler. You should also set the Parent property to a reference to the parent form so you can get that form's location on the screen.
 
Share this answer
 

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