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. Visual Basic
  4. Close a form from another form?

Close a form from another form?

Scheduled Pinned Locked Moved Visual Basic
winformshelpquestion
7 Posts 3 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.
  • D Offline
    D Offline
    Darshon
    wrote on last edited by
    #1

    Hello everyone, I have two windows forms, form1 has a close button that I would like to use to close not only form1 but also form2 at the same time if form2 is open. Is there a way to do this cause I cannot find anything that can help me with this?

    A M D 3 Replies Last reply
    0
    • D Darshon

      Hello everyone, I have two windows forms, form1 has a close button that I would like to use to close not only form1 but also form2 at the same time if form2 is open. Is there a way to do this cause I cannot find anything that can help me with this?

      A Offline
      A Offline
      albCode
      wrote on last edited by
      #2

      On Click event of your Close button do this Application.Exit()

      M 1 Reply Last reply
      0
      • D Darshon

        Hello everyone, I have two windows forms, form1 has a close button that I would like to use to close not only form1 but also form2 at the same time if form2 is open. Is there a way to do this cause I cannot find anything that can help me with this?

        M Offline
        M Offline
        matjame
        wrote on last edited by
        #3

        If you are running both forms(both open during running mode), you can always use, me.close that closes the current form and after that write form2.close(that is if your second form was initialized as form2.frm):-D:rolleyes: kagiso

        1 Reply Last reply
        0
        • A albCode

          On Click event of your Close button do this Application.Exit()

          M Offline
          M Offline
          matjame
          wrote on last edited by
          #4

          Oh, on your button click event, you do all those things. me.close form2.close this will close two forms and will leave other running forms,if you have any. kagiso

          A 1 Reply Last reply
          0
          • M matjame

            Oh, on your button click event, you do all those things. me.close form2.close this will close two forms and will leave other running forms,if you have any. kagiso

            A Offline
            A Offline
            albCode
            wrote on last edited by
            #5

            Dude he asked to close both forms form1 and form2 when he press close button on form1

            1 Reply Last reply
            0
            • D Darshon

              Hello everyone, I have two windows forms, form1 has a close button that I would like to use to close not only form1 but also form2 at the same time if form2 is open. Is there a way to do this cause I cannot find anything that can help me with this?

              D Offline
              D Offline
              Darshon
              wrote on last edited by
              #6

              Thanks guys, I'll try all of them cause I will need to exit certain forms only and also eventually the aplication in the end. Got two answers for the $0.00 price of one. ;)

              D 1 Reply Last reply
              0
              • D Darshon

                Thanks guys, I'll try all of them cause I will need to exit certain forms only and also eventually the aplication in the end. Got two answers for the $0.00 price of one. ;)

                D Offline
                D Offline
                Darshon
                wrote on last edited by
                #7

                Well I tried these suggestions and all I kept getting is that there was no instance set to an object and I've tried it many different ways and nothing BUT, I did find this article about Singletons which is letting me do exactly what I want. :) So for anyone that is having toubles like this here a good place to start looking >> http://www.codeproject.com/vb/net/Simple_Singleton_Forms.asp[^]

                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