MDI child is only visible when WindowState is Maximized

1.9k views Asked by At

I made a custom border for my mdi child. Mdi child form properties:

  • FormBorderStyle = None
  • Controlbox = False
  • Text = ""
  • WindowState = Maximized

First, when I had the property of Windowstate set to Normal, my mdi child would not appaer, I guess it has a size of 0;0 then. I tried setting the size in Form_Load method, but still nothing changed. When I changed FormBorderStyle to FixedSingle, I could see very tiny form with just enough space to double-click the title bar. Then the form really maximized.

I just don't understand anymore, this is all very confusing. And since the windowstate is maximized I can't use functions to drag the form around the screen because it thinks it's maximized....

enter image description here

2

There are 2 answers

0
Searush On

You have written "WindowState = Maximized".
Maybe because of this you only see your MDI Form when parent form is maximized.
I reccomend you write "WindowState = Normal" , and in Form_Load write "MDIForm.Size=ParentForm.Size" or (something like that).

0
Chiwda On

Try this code - guaranteed to work:

Public frmContainer As FormContainer
Public frmChild As FormChild

Public Sub OpenfrmChild()
    If Not IsNothing(frmChild) AndAlso frmChild.Visible = False Then 'This applies after form has been closed
        frmChild = Nothing '(frmChild does not test as nothing after being closed)
        frmChild = New FormChild
        frmChild.MdiParent = frmContainer
        frmChild.Show()
    ElseIf IsNothing(frmChild) Then 'This applies the first time form is opened
        Try
            frmChild = New FormChild
            frmChild.MdiParent = frmContainer
            frmChild.Show()
        Catch ex As Exception
            ErrorMsg(ex.Message() & "Description: " & ex.ToString)
        End Try
    Else 'This applies if form is visible and user clicks the button on FormChild again
        frmChild.BringToFront()
    End If
    frmChild.WindowState = FormWindowState.Maximized
    frmChild.Dock = DockStyle.Fill
 End Sub