Dear All,

I am developing a application where I have 1 parent from (windowstate of Parent from is set to Maximized) and 2 child forms. In my Parent form I have a menustrip with following code to activate child -

Public Class FormParent
    Public NewMDIChildForm1 As New Form1()
    Public NewMDIChildForm2 As New Form2()

    Private Sub AddChlid1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddChild1ToolStripMenuItem.Click

            NewMDIChildForm1.MdiParent = Me
            NewMDIChildForm1.WindowState = FormWindowState.Maximized
            NewMDIChildForm1.Show()
    End Sub

Private Sub AddChlid2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddChlid2ToolStripMenuItem.Click

            NewMDIChildForm2.MdiParent = Me
            NewMDIChildForm2.WindowState = FormWindowState.Maximized
            NewMDIChildForm2.Show()
    End Sub
End Class

I have buttons on each child form with

me.hide

now when I do following steps

Open Child Form1 - Open Child Form2 - Hide Child Form2 - Hide Child Form1 - Open Child Form1

my Child form1 doesnot appears in Maximized state

Please Help.

Regards,

Pankaj

Alot of times when I go to open a form I suse the following code:

If (My.Forms.ChildFormName.WindowState = 1) Then     'WindowState = 2 (maximized) / WindowState = 1 (minimized) / WindowState = 0 (normal)
            My.Forms.ChildFormName.WindowState = 0
            My.Forms.ChildFormName.Activate()
        Else
            My.Forms.ChildFormName.Visible = True
            My.Forms.ChildFormName.WindowState = 0
            My.Forms.ChildFormName.Activate()
        End If

What this does is ... if the form is already open, but is minimized, then this will maximize the form and make it the active form. If the form is not open, then it will open the form and make it the active form. Works like a charm in my applications.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.