Results 1 to 4 of 4

Thread: Mdi

  1. #1

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

    Mdi

    I'm using this code to determine if an instance of the form is already open, but I get an error...any suggestions?

    Code:
    Dim frmdataentry1 As frmDataEntry = Nothing
            If frmdataentry1 Is Nothing Then
                frmDataEntry1 = New frmDataEntry()
                frmDataEntry1.MdiParent = Me
                frmDataEntry1.Show()
             End If

    Additional information: The form that was specified to be the MdiParent for this form is not an MdiContainer.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I don't believe you can set a non MDI Container to be an MDI Parent, but you didn't mention what error you are getting. Also the way you have that code the IF is not needed as it will always be true. You set the object to nothing and then on the next line test if it is nothing or not, but since you just set it to be nothing it will always be true.

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I guess that explains why it's not working...Any adive on what I can do to check if a child form is already running in the parent and if it is, make it the active form?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could loop through the MDIChildren and see if any of them are of the type you need. There might be a better way but that should work.

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         'find a form in the children of type form1
    3.         Dim frm As Form
    4.         For Each frm In Me.MdiChildren
    5.             If frm.GetType Is GetType(Form1) Then
    6.                 frm.Activate()
    7.             End If
    8.         Next
    9.     End Sub

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