Results 1 to 3 of 3

Thread: [RESOLVED] open form on button click

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Denmark
    Posts
    67

    Resolved [RESOLVED] open form on button click

    Im using this code atm,
    VB Code:
    1. private void button2_Click(object sender, EventArgs e)
    2.         {
    3.             Form2.ActiveForms();
    4.         }

    but it wont work, and the Form2.open wont either... how do you open a new form on button click, Ive allready created the form so i just need to open it.

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: open form on button click

    You first need to create an instance of the form and then open that.
    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                Form2 f = new Form2();
                f.Show();
            }

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Denmark
    Posts
    67

    Re: open form on button click

    [edit] my bad, i forgot that C# is case sensitive...

    heres the code

    Code:
            private void button2_Click(object sender, EventArgs e)
            {
                Form2 f = new Form2();
                f.Show();
    
                /*MessageBox.Show("This function is not implemented yet");*/
            }
    Thx btw
    Last edited by RoflJOE; Nov 19th, 2006 at 11:29 AM.

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