Can an MDI child close and MDI parent?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RGF2ZVA=?=

    #1

    Can an MDI child close and MDI parent?

    I've got a situation in a VB 2003 Windows application with an MDI form and a
    child form. In certain situations, when the child is closed by the user, I
    also want to close the MDI parent. Is there a way to close the MDI parent
    with code in the child form?

    In the MDI child form, I have tried:

    me.MDIParent.Cl ose

    but that doesn't appear to work. Is that because of object references in
    the parent that are still alive? Is this even possible?

    Thanks!
  • Gillard

    #2
    Re: Can an MDI child close and MDI parent?

    Form1.Close 'Form1 is the parent

    "DaveP" <DaveP@discussi ons.microsoft.c omwrote in message
    news:9F636BF3-0C2A-47A0-A096-75CBA4CDE368@mi crosoft.com...
    I've got a situation in a VB 2003 Windows application with an MDI form and
    a
    child form. In certain situations, when the child is closed by the user,
    I
    also want to close the MDI parent. Is there a way to close the MDI parent
    with code in the child form?
    >
    In the MDI child form, I have tried:
    >
    me.MDIParent.Cl ose
    >
    but that doesn't appear to work. Is that because of object references in
    the parent that are still alive? Is this even possible?
    >
    Thanks!

    Comment

    • Family Tree Mike

      #3
      Re: Can an MDI child close and MDI parent?

      Gillard, Form1.Close looks like a static method call on class Form1. Is
      that what you meant?

      DaveP, It is possible to close the app from the child forms. I would raise
      an event for the main app to handle the close operation.

      "Gillard" <gillard_george s@@@@@@@@@hotma il.comwrote in message
      news:%23WHRXddG JHA.3928@TK2MSF TNGP03.phx.gbl. ..
      Form1.Close 'Form1 is the parent
      >
      "DaveP" <DaveP@discussi ons.microsoft.c omwrote in message
      news:9F636BF3-0C2A-47A0-A096-75CBA4CDE368@mi crosoft.com...
      >I've got a situation in a VB 2003 Windows application with an MDI form
      >and a
      >child form. In certain situations, when the child is closed by the user,
      >I
      >also want to close the MDI parent. Is there a way to close the MDI
      >parent
      >with code in the child form?
      >>
      >In the MDI child form, I have tried:
      >>
      > me.MDIParent.Cl ose
      >>
      >but that doesn't appear to work. Is that because of object references in
      >the parent that are still alive? Is this even possible?
      >>
      >Thanks!
      >

      Comment

      • James Hahn

        #4
        Re: Can an MDI child close and MDI parent?

        The idea of tryng to close the parent from the child never seemed qute
        proper to me. The technique I have used is for the child to change a
        property of the parent as it is closing, and then to put the code to clean
        up the other children and close down the parent in the change event for that
        parent property. At first it seemed like a kludge, but in practice it is
        very effective. Of course, you should choose a property of the parent that
        the user isn't going to change. For instance, change the text of the parent
        to "Closing", and put the shutdown code in the parent's textchanged event.

        "DaveP" <DaveP@discussi ons.microsoft.c omwrote in message
        news:9F636BF3-0C2A-47A0-A096-75CBA4CDE368@mi crosoft.com...
        I've got a situation in a VB 2003 Windows application with an MDI form and
        a
        child form. In certain situations, when the child is closed by the user,
        I
        also want to close the MDI parent. Is there a way to close the MDI parent
        with code in the child form?
        >
        In the MDI child form, I have tried:
        >
        me.MDIParent.Cl ose
        >
        but that doesn't appear to work. Is that because of object references in
        the parent that are still alive? Is this even possible?
        >
        Thanks!

        Comment

        Working...