Centre form in MDI

  • Thread starter Thread starter 99pshop via .NET 247
  • Start date Start date
9

99pshop via .NET 247

Hi

Am new to VB.NET and wondering how to centre my form in the mdi that is maximised or set to a diferent size.

I tried this
wTop = (frmMDI.Size.Height - frm.Size.Height) \ 2
wLeft = (frmMDI.Size.Width - frm.Size.Width) \ 2
frm.Location = New Point(wLeft, wTop)

Main problem is when the mdi form is maximised, the size reported is not the new size but the size set at design time.
 
Form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
 
Hi Brian,
Following up...I tried to put a form in a panel and use the
CenterParent and it did not work. The form kept being displayed in the
upper left corner of the panel. Here is what I did:

Dim objForm as New Form1
objForm.TopLevel = False
Panel1.Controls.Add(objForm)
objForm.StartPosition = FormStartPosition.CenterParent
objForm.Show()

What did I do wrong?

TIA,
John

Form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top