0

I am having a basic problem opening a child form in an mdiForm.

Dim frm As New Form1
frm.MdiParent = Me
frm.Show()

I have some code in the Form-Load event of the child form to open up connection to access db (connection opens fine).

Try
   conn.Open()
catch ex As Exception
   Msgbox("connection error")
End Try

MdiForm is set to open up in a Maximized state. When the app runs, mdiForm opens up normal and the Menustrip looks normal size as well. However, when I try to open up a child form (Form1 in this case) from the MenuStrip, the mdiForm remains in Maximized state but no longer covers the screen and the menustrip shrinks (the words become much smaller fonts) and then the form objects (labels and textboxes) also get smaller. If i comment the code in Form-Load i do not get this problem.

I would like everything to remain the same size just before the child form was opened.

Maz
  • 245
  • 3
  • 11
  • 1
    Hi Maz, have you tried, in the properties of the form, to set the maximum, minimum and current size all to be equal? – David Jul 19 '16 at 10:08
  • Thanks David for the reply. Yes i tried that still the same thing. – Maz Jul 19 '16 at 17:15
  • 1
    Try to step through the code, and see where, if at all, it's setting the size of the form. Do you have anything in the solution explorer called `something.Designer`? It may also be worth checking in there – David Jul 20 '16 at 09:47
  • I already did that. When i comment "conn.open()" it works fine. but when i keep it uncommented it acts this way. conn is OLEDB.OLEDBConnection put in a try catch block. so i am not sure why this is causing the form to change. – Maz Jul 20 '16 at 17:18
  • 1
    It sounds to me like you're opening with two connections/constructors? When you leave `conn.Open()` commented out, does the data that the form is supposed to be getting still get displayed? – David Jul 21 '16 at 08:25
  • no, i am not using any objects or wizards just by code. connectionstring of conn is delcared in the main form so i just open it in form load event. how does that affect the display of the form. – Maz Jul 21 '16 at 08:37
  • Hi Maz, it might help if you added all of the code for the form that is becoming smaller, someone then may spot a problem – David Jul 21 '16 at 09:45
  • Hi David, i think its an issue with vs.net 2015 i tried it on 2013 and it worked fine – Maz Jul 22 '16 at 05:05
  • 1
    Hmm, that's weird.... I have no idea why that might be, but at least you found a solution to it – David Jul 22 '16 at 08:05

0 Answers0