MDI app 
Author Message
 MDI app

I have a MDI app, and if my user clicks on say a button that creates a child
form, then clicks it again the form obviously is created twice. How can I
tell if the child form already exists. And I mean that specific chilc form
not just all child forms or any.

Thanks



Sat, 29 Jan 2005 08:07:21 GMT  
 MDI app
You can use a shared count variant in the child form. for example:

    Shared FormCount As Integer

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        FormCount = FormCount + 1
        If FormCount > 1 Then

            Me.Close()
        End If
    End Sub

    Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
        FormCount = FormCount - 1
    End Sub

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Sat, 29 Jan 2005 11:08:05 GMT  
 MDI app
This is how I do it.  The function returns True if the child form is already
in the MdiChildren collection.

Function IsFormOpen(ByVal frmParent As Form, ByVal frmTest As Form) As
Boolean

    Dim fTemp As Form
    Dim bOpen As Boolean = False

    For Each fTemp In frmParent.MdiChildren
        If fTemp Is frmTest Then bOpen = True : Exit For
    Next

    Return (bOpen)

End Function


Quote:
> I have a MDI app, and if my user clicks on say a button that creates a
child
> form, then clicks it again the form obviously is created twice. How can I
> tell if the child form already exists. And I mean that specific chilc form
> not just all child forms or any.

> Thanks



Sat, 29 Jan 2005 19:02:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MDI app calls another MDI app

2. MDI Apps

3. Flickering Forms in mdi App

4. Master Data Control in MDI App?

5. Identifying the active form in an MDI App

6. Opening Several Files in MDI App

7. Problem with MDI app negotiating toolbars

8. Unloading forms from MDI App

9. Extract icons from child form in MDI app?

10. Need Help With PopMenu In An MDI App

11. Opening API EXEs from within VB MDI app.

12. Create Docking Form in MDI app

 

 
Powered by phpBB® Forum Software