Solved

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

Posted on 2004-10-05
4
507 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
Comment Utility
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 25 total points
Comment Utility
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
Comment Utility
lol...emoreau...the link I posted is your solution.

~IM
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
seems that you agree with it!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now