Search code examples
vb.netmdiparent

Mdiparent ,child forms


I have mdiparent and many child forms im calling a child form as below

     Private Sub tsmQuotation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmQuotation.Click
            If Application.OpenForms().OfType(Of Quotation).Any Then
                 Quotation.WindowState = FormWindowState.Normal
                 Quotation.Focus()
            Else
                 Quotation.MdiParent = Me
                 Quotation.Show()
            End If
     End Sub

my first doubt is: when i declare this Quotation.MdiParent = Me...it takes more time to open the form than without this line. How can i reduce the time to open form..or am I doing anything wrong ?

2nd doubt is: I have place a picturebox in mdiparent's center. and i have sent picturebox to back but then too when i open any child form I see the picturebox above the quotaion .I want to show picture box at back not above any child forms.

Thanks in advance!!!


Solution

  • Without Quotation.MdiParent = Me, the form displayed would not be an MdiChild. It would instead be displaying as a normal form by itself. Try dragging it around the screen and you'll see that it is not confined to the MdiParent form.

    See if this loads it any faster, though:

    Private Sub tsmQuotation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmQuotation.Click
        If Application.OpenForms().OfType(Of Quotation).Any Then
            Dim Q As Quotation = Application.OpenForms().OfType(Of Quotation).First
            Q.WindowState = FormWindowState.Normal
            Q.Activate()
        Else
            Dim Q As New Quotation
            Q.MdiParent = Me
            Q.Show()
        End If
    End Sub
    

    For the second issue, select the MdiParent form and set the BackgroundImage() and BackgroundImageLayout() properties. The image will NOT display on the form at design-time, but it will be there when you run the application.