How to: Display One Form from Another

This example displays a second form from a Windows Form.

This example requires two Windows Forms named Form1 and Form2.

  • Form1 contains a Button control named button1.


To create Form1

  1. Create a Windows Forms Application, and name it Form1.

  2. Add a Button control to the form, and name it button1.

  3. Add the Form2 class to the namespace, and set the Click event handler of button1 as shown in the following code.

    When you click the button, Form2 will be displayed.


private void button1_Click(object sender, System.EventArgs e)
    Form2 frm = new Form2();
// Create Form2.
public class Form2: Form
    public Form2()
        Text = "Form2";

See Also


Designing a User Interface in Visual C#

Other Resources

Customizing, Displaying, and Printing Windows Forms

Visual C# Guided Tour