Results 1 to 8 of 8

Thread: mdi closing child

  1. #1

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

    mdi closing child

    I need to close a child form when a button is clicked on another child form.

    I'm using:

    pcms.frmDataEntry1.Close() - on the click event but get an error


    Object reference not set to an instance of an object.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Just use a loop:

    Dim frmMain as Form=Me.MdiParent
    Dim frm as Form

    If frmMain.MdiCHildren.Length > 0 then
    For Each frm in frmMain.MdiChildren
    If frm.text="Data Form" then
    frm.close()
    End IF
    Next
    End If

  3. #3

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

    another question...how can I call a procedure in different child form?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this example I posted here . It's not MDI but the concept you'll apply is the same I beleive plus you need to reference the parent form to the current form you're working on . http://www.vbforums.com/showthread.p...hreadid=275354

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    hey pirate, I was unable to open your example.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by EyeTalion
    hey pirate, I was unable to open your example.
    It's winrar file (you need winrar to unpack it) and the project is VB.NET 2003 . What's the problem ?

  7. #7

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    still trying to call a procedure from one child form to another in a mdi
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  8. #8
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Private sub btnOpen ..... Handles btnOpen.Click

    Dim frmMain as Form=Me.MdiParent
    Dim frm as Form

    If frmMain.MdiCHildren.Length > 0 then
    For Each frm in frmMain.MdiChildren
    If frm.text="Data Form" then


    Dim frmData as frmData = frm ' the form with the function on it
    Exit For

    End IF
    Next
    End If

    frmData.yourfunctionname(sender,e) ' call your function

    End Sub

    Haven't tried it but it should work!

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