Question: I have two Forms, Form1 and Form2. I want Form2 to load when I debug the program, and then on a btnclickevent (in Form2) close Form2 and load Form1 plus import a input value from a textbox to my code in Form1.

Please let me know if somethings needs to be claryfied.

```
 private void Form1_Load(object sender, EventArgs e)
    {
        Form2 f2 = new Form2();
        f2.Show();
     } 

```

Answer: 
What form is displayed first is determined by the Main() method in Program.cs. You could for example make it look like this:

```
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Form main;
        if (System.Diagnostics.Debugger.IsAttached) main = new Form2();
        else main = new Form1();
        Application.Run(main);
    }

```

Which still makes it hard to get Form1 displayed after Form2, you could tackle it this way:

```
        if (System.Diagnostics.Debugger.IsAttached) {
            using (var debug = new Form2()) {
                if (debug.ShowDialog() != DialogResult.OK) return;
            }
        }
        Application.Run(new Form1());

```
> 
> I want Form2 to load when I debug the program  
> 
> 
> 
> 

Go into `Program.cs` and change this : 

```
static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

```

with this : 

```
 static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form2());
    }

```

> 
> and then on a btnclickevent (in Form2) close Form2 and load Form1
> 
> 
> 

Put this in **form2**. You could read about [Lambda expressions](http://msdn.microsoft.com/en-us/library/vstudio/bb397687.aspx) and [Anonymous methods](http://msdn.microsoft.com/en-us/library/0yw3tz5k%28v=vs.80%29.aspx) if you don't understand the syntax.

```
someButton.Click += (s, e) => 
{
Form1 form1 = new Form1();
form1.Show();
this.Close();
};

```

> 
> plus import a input value from a textbox to my code in Form1
> 
> 
> 

Oh.. Well since we don't like to use static stuff we will change the constructor of **form1** to make sure it represents it's purpose. (Since **form1** needs needs some text from a textbox when it is created, it should receive it in the constructor of it's class).

So put a field / property to **form1** and set it in it's constructor. (Make sure it receives a string)

```
public Form1 (string someText)
{
  //set it
}

```

And now all you have to do is change the call done in the other form.

```
someButton.Click += (s, e) => 
{
Form1 form1 = new Form1(myTextBox.Text);
form1.Show();
this.Close();
};

```