Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. closing an open form

closing an open form

Scheduled Pinned Locked Moved C#
questionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gonad
    wrote on last edited by
    #1

    i have a treeview control with about 20 subnodes. each time i click on a new node, a related form opens in the parent window. how can i close the currently opened form once a new node is selected in the treeview control? thanks for your help. :)

    Z 1 Reply Last reply
    0
    • G gonad

      i have a treeview control with about 20 subnodes. each time i click on a new node, a related form opens in the parent window. how can i close the currently opened form once a new node is selected in the treeview control? thanks for your help. :)

      Z Offline
      Z Offline
      zuhx
      wrote on last edited by
      #2

      First you will need to grab a reference to the parent window and the active window. Then you can close the active window. What I did was set a reference to the parent window in a var. Then I was able to call the variable and get the ActiveMdiChild property and set that property to close. So I have something like this if (parent.ActiveMdiChild != null) { parent.ActiveMdiChild.Close(); }

      G 1 Reply Last reply
      0
      • Z zuhx

        First you will need to grab a reference to the parent window and the active window. Then you can close the active window. What I did was set a reference to the parent window in a var. Then I was able to call the variable and get the ActiveMdiChild property and set that property to close. So I have something like this if (parent.ActiveMdiChild != null) { parent.ActiveMdiChild.Close(); }

        G Offline
        G Offline
        gonad
        wrote on last edited by
        #3

        thank you for your help. it worked exactly like you said. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups