Newbie Question

Okay, I have decided to learn C#, so I created a basic form in Visual Studio C# 2005 (Not Express). What is the code to show Form2 For example Form1 has a button when the user clicks the button in Form1 it shows Form2. What is the code to do that


Answer this question

Newbie Question

  • Victor F Rodriguez

    I do something like,

    FormClassName frmstart = new FormClassName();

    frmStart.Show();

    Jeff


  • Haicheng

    I did this code


    public partial class Form1: Form
    {
    Form2 f2;
    public MainWindow()
    {
    InitializeComponent();
    f2 = new Form2();
    f2.Visible = false;
    }

    private void button1_Click(object sender, EventArgs e)
    {
    f2.Visible = true;
    }
    }

    And under MainWindow() it is highlighted red. What should I do

  • (H)MICHAEL(H)

    s/MainWindow/Form1

     

    Sorry about that, I had a differnt name for the form, I thought I changed all occurances.

     

    And you can also do f2.Show(), it does the same thing.



  • ale_vera_0603

    public partial class Form1: Form
    {
    Form2 f2;
    public MainWindow()
    {
    InitializeComponent();
    f2 = new Form2();
    f2.Visible = false;
    }

    private void button1_Click(object sender, EventArgs e)
    {
    f2.Visible = true;
    }
    }



  • Newbie Question