closing both forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itaye666
    New Member
    • Jan 2010
    • 3

    closing both forms

    im trying to open one form while closing another form with a link label.
    what im using is this:
    private void linkLabel1_Link Clicked(object sender, LinkLabelLinkCl ickedEventArgs e)
    {
    Form2 frm = new Form2();
    frm.Show();
    this.close();
    }
    but it closes both forms and exiting the debug

    plz help me! T_T
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If you exit the first form, the second one will go out of scope and be closed too.
    Try re-thinking the structure of your program.
    Or consider just hiding (and then later showing if need be) the first form

    Comment

    • mzmishra
      Recognized Expert Contributor
      • Aug 2007
      • 390

      #3
      Try something like this.
      private void CloseAndOpen(Fo rm currentForm, Form openForm)

      {



      openForm.Show() ;

      currentForm.Hid e();

      }





      private void linkLabel1_Link Clicked(object sender, EventArgs e)

      {

      CloseAndOpen(th is, new Form3());

      }

      Comment

      • itaye666
        New Member
        • Jan 2010
        • 3

        #4
        tnx guys

        tnx but what i did is i created an extra form with copy rights etc. and made it the main form and it opens the first one on start so now when i close the first one the secont doesnt closes but tnx i might use your idea in my next prog

        Comment

        Working...