Results 1 to 3 of 3

Thread: using ShowDialog

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    using ShowDialog

    I have a MDI Parent Form with a menu bar. The user can open the forms they need from here. The problem I'm having is with a MDI form you can't use ShowDialog on a child form, so if you want to open the same form a 100 times, you can. Is there a way to stop this or at least test to see if the form is already open?

    thanks,
    eye

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    i guess you could check to see if the form class for thta form is nothing

    Code:
    If yourformcalssname Is Nothing Then
       ' Load the form
    Else
      ' Dont load the form
    End If
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    This is perhaps not as elegant a solution but it works for me. I have a function that rifles thru the MDI childforms to find a prior instance like this:
    VB Code:
    1. ' Check for previous instance of the child form and activate it if found, otherwise return False
    2.     Friend Function fCheckInstance(ByRef frmParent As Form, ByRef szChild As String) As Boolean
    3.  
    4.         fCheckInstance = True
    5.  
    6.         Dim frmInstanceCheck As Form
    7.         ' See if the form is already open
    8.         For Each frmInstanceCheck In frmParent.MdiChildren
    9.             If frmInstanceCheck.Text = szChild Then
    10.                 frmInstanceCheck.Activate()
    11.                 Exit Function
    12.             End If
    13.         Next
    14.  
    15.         fCheckInstance = False
    16.  
    17.     End Function

    I call it when the user attempts to open a child form thusly:
    VB Code:
    1. If Not fCheckInstance(Me, "MasterEdits") Then
    2.    Dim frm As New MasterEdits()
    3.    frm.MdiParent = Me
    4.    frm.Show()
    5. End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width