problems with mdi forms c#

I'm having a few problems with some child forms. I set the Locked field to True because I dont want the user to be able to move the form, but they still can move it. I also try and center the form in the Parent form and it does not do anything. Here is my code:

in MainCOE form under form_Load:

LoadVendor l = new LoadVendor();
l.MdiParent = this;

in LoadVendor under form_Load:


When I run, the form shows up properly but i can move it around and it is also not centered. Any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To center the MDI Child Form, use:

l.StartPosition = FormStartPosition.CenterScreen;

Yes, even if your MDI Parent Form isn't centered, the child form will be centered in the parent form.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You cannot make the child form stay fixed in the parent form by just chaning a property. You can try catching move events and returning the form in the center every time the user tries to change the position. You can do this by writing the following code in your child form class' code:

protected override void WndProc( ref Message m )
  const int WM_NCLBUTTONDOWN = 161;
  const int WM_SYSCOMMAND = 274;
  const int HTCAPTION = 2;
  const int SC_MOVE = 61456;

  if ( (m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() == SC_MOVE) )
  if ( (m.Msg == WM_NCLBUTTONDOWN) && (m.WParam.ToInt32() == HTCAPTION) )

  base.WndProc( ref m );

mbosicoAuthor Commented:
thanks guys

is there a reason why the CenterToParent() method didnt do anything?
CenterToParent() will only work if you have, say, a button (child) on a form (parent).  You cannot make a top level control (a form) a child (i.e. to another form), therefore there is nothing to center it to!
mbosicoAuthor Commented:
thanks, makes sense
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.