How do i open a new form when i click a button?

Discussion in 'Programming General' started by hampe-92, Sep 21, 2008.

How do i open a new form when i click a button?
  1. Unread #1 - Sep 21, 2008 at 4:03 AM
  2. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    How do i open a new form when i click a button?

    I need some help here... let's say I start out with a form, called "Form1"
    when I have edited that so it looks just like I want it, then I want to make it open a form called "Form2" when I click a button... how can I possibly do that??
    thx in advance!:)
     
  3. Unread #2 - Sep 21, 2008 at 4:30 AM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    How do i open a new form when i click a button?

    You need to create a new form and call its Show method.

    Code:
    private void button_Click(object sender, EventArgs e)
    {
        Form form = new Form();
        form.Show();
    }
     
  5. Unread #3 - Sep 21, 2008 at 4:38 AM
  6. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    How do i open a new form when i click a button?

    yay it works :D tyvm!:)

    EDIT: hmm :/ i wrote:
    Code:
    private void button_Click(object sender, EventArgs e)
    {
        Form Form2 = new Form();
        Form2.Show();
    }
    and that opens up a new form, but not my form, "Form2", that i have made... it just opens a blank new form :confused:
     
  7. Unread #4 - Sep 21, 2008 at 4:48 AM
  8. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    How do i open a new form when i click a button?

    It should be:
    Code:
    Form2 form = new Form2();
     
  9. Unread #5 - Sep 21, 2008 at 4:50 AM
  10. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    How do i open a new form when i click a button?

    ohh tysm for the help! now it's working just as it is suposed to!:)
     
  11. Unread #6 - Sep 21, 2008 at 11:19 AM
  12. BigBwoi2001
    Joined:
    Jul 4, 2008
    Posts:
    54
    Referrals:
    0
    Sythe Gold:
    0

    BigBwoi2001 Member

    How do i open a new form when i click a button?

    Code:
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(New FormName());
    this.hide();
     
  13. Unread #7 - Sep 21, 2008 at 11:47 AM
  14. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    How do i open a new form when i click a button?

    thx but it works just fine that way Flaming said.. ;)
    and beside, i don't want form1 to be closed when i open form2 :p but thx anyway, it might come in handy l8er some time:)
     
  15. Unread #8 - Sep 21, 2008 at 5:01 PM
  16. BigBwoi2001
    Joined:
    Jul 4, 2008
    Posts:
    54
    Referrals:
    0
    Sythe Gold:
    0

    BigBwoi2001 Member

    How do i open a new form when i click a button?

    Well incase you wanted to close form1 you could use that method also.
     
  17. Unread #9 - Sep 21, 2008 at 5:34 PM
  18. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    How do i open a new form when i click a button?

    what u mean? your or his method?
     
< Which language? | Htaed Searcher >

Users viewing this thread
1 guest


 
 
Adblock breaks this site