Solved

Make MDI Parent open only one (same) MDI Child form

Posted on 2004-10-05
4
509 Views
Last Modified: 2011-09-20
hi Experts,

i want to ask How to make MDI Parent open only one (same) MDI Child form?
so it will like in VB6 where i can only open one MDI Child form...
i will need to close the opened MDI child form first if i want to open the same MDI child form again
Note: i will still be able to open different MDI child forms

thanks in advance
0
Comment
Question by:Axpress
  • 2
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 25 total points
ID: 12227330
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 25 total points
ID: 12227569
You need to loop thouch the MDIChildren collection to find if an instance of a particular child is already loaded.

    Private Function IsChildInMemory(ByVal pChildName As String) As Boolean
        'A small method that checks to see if a particular form is currently displayed as a child form
        Dim frmChild As Form
        For Each frmChild In Me.MdiChildren
            If TypeName(frmChild).ToUpper = pChildName.ToUpper Then
                frmChild.Activate()
                Return True
            End If
        Next
        Return False
    End Function

Then you can use this code:

If Not IsChildInMemory("frmChild2") Then
    Dim frm As New frmChild2()
    With frm
        .MdiParent = Me
        .Show()
        '.Dock = DockStyle.Fill
    End With
End If
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12228613
lol...emoreau...the link I posted is your solution.

~IM
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 12228946
seems that you agree with it!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question