Solved

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

Posted on 2004-10-05
4
510 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - TypeInitializer Error 25 32
vb.net winforms sizing/resolution? 4 43
Passing data between Forms 3 20
VB.net Open video relating to control 2 20
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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