Results 1 to 27 of 27

Thread: how to close form1 when i open form2?

Hybrid View

  1. #1
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: how to close form1 when i open form2?

    Quote Originally Posted by fifo
    It does not work. It will close both form because this code must be in Button_Click of form1 so that when you call This.Close() --> form1 will be Close with all of this code will be close, too.

    Any ideas?
    VB Code:
    1. this.Hide();
    2. Form2 newform = new Form2();
    3. newform.Show();

    This way the form's still open (in theory), however calling application.exit(); to close everything, will close that form too.

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: how to close form1 when i open form2?

    Quote Originally Posted by RudiVisser
    VB Code:
    1. this.Hide();
    2. Form2 newform = new Form2();
    3. newform.Show();

    This way the form's still open (in theory), however calling application.exit(); to close everything, will close that form too.
    the error with this code is that you should be declaring 'newform' with the type 'Form' not the type 'Form2:

    Code:
    this.Hide();
    Form newform = new Form2();
    newform.Show();
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: how to close form1 when i open form2?

    Quote Originally Posted by tr333
    the error with this code is that you should be declaring 'newform' with the type 'Form' not the type 'Form2:

    Code:
    this.Hide();
    Form newform = new Form2();
    newform.Show();
    No, it's not.
    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

  4. #4
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: how to close form1 when i open form2?

    Quote Originally Posted by RudiVisser
    No, it's not.
    Follow-up: Because there was no error..
    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

  5. #5
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: how to close form1 when i open form2?

    Quote Originally Posted by RudiVisser
    Follow-up: Because there was no error..
    (i thought i saw earlier in this thread that someone had an error with the code. didn't test it myself )
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width