Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Child Form not Centering
 

Child Form not Centering

I am in the process of developing an MDI application in VB.NET (2005). Anyway, my child form's refuse to center the parent forms bounds. I have tried setting the 'startposition' via the properties menu. I have also tried setting the 'startposition' with code in the parent form's load procedure. Here is the code I used.

frmMain.StartPosition = FormStartPosition.CenterParent

Note: frmMain is the name of the child form. Whenever I run the application, the child form is loading in the default upper-left hand corner of it's parent form.

If anybody has a possible solution, I would greatly appreciate it. Thanks for any help.

B.H.
bcheath  Thursday, April 06, 2006 9:52 PM

You need to define the StartPosition for the child form and not for the parent form. You example shows 'frmMain' being changed where it needs to be 'frmChild' or whatever you have called it.

Hope that helps,
Phil Wright
http://www.componentfactory.com
Free UI controls for .NET2

Philip Wright  Monday, April 10, 2006 8:57 AM

You need to define the StartPosition for the child form and not for the parent form. You example shows 'frmMain' being changed where it needs to be 'frmChild' or whatever you have called it.

Hope that helps,
Phil Wright
http://www.componentfactory.com
Free UI controls for .NET2

Philip Wright  Monday, April 10, 2006 8:57 AM
It seems a little confusing, but "frmMain" is the name of the child form. I provided the code that I attempted to use to set the child form in place. I have my parent form as being named "frmMdi".

I do realize the difference between the parent and child forms. I hope this helps to clarify the difficulty I am having.

Thanks again for your time,

Brad Heath
bcheath  Monday, April 10, 2006 9:33 PM

Form.Show does not seem to bother looking at whatever is present in the FormStartPosition. If you use ShowDialog instead that would position it correctly.

I've used the Form.SetDesktopLocation() method in the FormLoad event to place the form where I want it to get around these problems

Windchaserb  Wednesday, May 23, 2007 5:56 PM

You can use google to search for other answers

Custom Search

More Threads

• CollectionEditor only calls DestroyInstance for items added during current session
• Help, I experiece this kind of errors
• Overlaying a Windows Form on a Direct3d window
• UITypeEditor for inheritors of DataTable
• Disable Enter in GridColumnStyle
• Handling Font Style in UserControl
• Binding TextBox's Text property to application settings and setting UseSystemPasswordChar to true
• design time
• Input number in TextBox Error When I type Unicode in TextBox ?
• Move scrollbar at top position