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. Open Form Problem

Open Form Problem

Scheduled Pinned Locked Moved C#
help
6 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.
  • E Offline
    E Offline
    Expert Coming
    wrote on last edited by
    #1

    This code doesn't seam to work, it opens both as planned, but the frmCreate opens for 1/4 second or so, help please. The code: private void mnuLogin_Click(object sender, System.EventArgs e) { Form openform = new frmCreate(); this.Close(); openform.Show(); }

    D 1 Reply Last reply
    0
    • E Expert Coming

      This code doesn't seam to work, it opens both as planned, but the frmCreate opens for 1/4 second or so, help please. The code: private void mnuLogin_Click(object sender, System.EventArgs e) { Form openform = new frmCreate(); this.Close(); openform.Show(); }

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Of course it does! You closed the form (this) that is the only thing holding a reference to the new form you created. If Form1 creates Form2 and show it, then Form1 closes, Form2 is going to close it since nothing else is holding a reference to Form2. You can't "transfer" control of your application from form to form to form. You have to have a "parent" form that creates your other forms to keep their references alive. Those "child" forms can have their own "child" forms, and so on down the line. It'll look like a hierarchy when your done.

             Startup Form
                  |
          +-------+-------+
          |               |
        Form2           Form3
          |
      

      +----+----+
      | |
      Form4 Form5

      In this example, if you Close Form2, Forms4 and 5 are going to vanish too, because Form2 created and was holding the references for 4 and 5. In your code, you did just that. Your (this) form created a new form object called frmCreate, then killed itself, taking the newly created form with it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Of course it does! You closed the form (this) that is the only thing holding a reference to the new form you created. If Form1 creates Form2 and show it, then Form1 closes, Form2 is going to close it since nothing else is holding a reference to Form2. You can't "transfer" control of your application from form to form to form. You have to have a "parent" form that creates your other forms to keep their references alive. Those "child" forms can have their own "child" forms, and so on down the line. It'll look like a hierarchy when your done.

               Startup Form
                    |
            +-------+-------+
            |               |
          Form2           Form3
            |
        

        +----+----+
        | |
        Form4 Form5

        In this example, if you Close Form2, Forms4 and 5 are going to vanish too, because Form2 created and was holding the references for 4 and 5. In your code, you did just that. Your (this) form created a new form object called frmCreate, then killed itself, taking the newly created form with it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        E Offline
        E Offline
        Expert Coming
        wrote on last edited by
        #3

        How do I HIDE the form or something so frmCreate can be seen?

        G D 2 Replies Last reply
        0
        • E Expert Coming

          How do I HIDE the form or something so frmCreate can be seen?

          G Offline
          G Offline
          grim_zax
          wrote on last edited by
          #4

          try the opacity property its me =Þ grim zax

          1 Reply Last reply
          0
          • E Expert Coming

            How do I HIDE the form or something so frmCreate can be seen?

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            You don't look through the Intellisense list much, do you? You just said it yourself -> this.Hide()[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            E 1 Reply Last reply
            0
            • D Dave Kreskowiak

              You don't look through the Intellisense list much, do you? You just said it yourself -> this.Hide()[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              E Offline
              E Offline
              Expert Coming
              wrote on last edited by
              #6

              I said that as I found it in the list lol.

              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