So basically what I want to do is when user clicks button1 it pops up something like a message box that has a yes and a no button. If user clicks no, then it's no. If user clicks yes, then it's yes. It's like a confirmation. To do so, I want to make a new windows form application appear when you click that button.

So two questions really:

1. How to make that happen
2. How to share data between the windows. (I need to tell my original window that the user pressed yes or no)

DialogResult result = MessageBox.Show("Please select yes or no", "Yes, no?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes) {
                // they pressed yes
            } else {
                // they pressed no
            }

There are a lot of other options for MessageBox, you should read up about them :)

DialogResult result = MessageBox.Show("Please select yes or no", "Yes, no?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes) {
                // they pressed yes
            } else {
                // they pressed no
            }

There are a lot of other options for MessageBox, you should read up about them :)

Yeah that helps, but that's not my core question. I'm really asking how to initiate a second form and SEND INFORMATION between them. So I can access a text box on Form 2 in form 1.

You send information, usually, in the Form2 constructor. Create a new constructor that has parameters for whatever information you need to send back to form1. To get access to the text box on form2, the best way is to create a public property that gives read access:

Somewhere in form2:

public String TextBoxData {
    get {
        return myTextBox.Text;
    }
}

Now in form1 you'd do something like

Form2 myForm2 = new Form2(parameters go here);
myForm2.ShowDialog();  // force user to interact with form2
String valueFromForm2 = myForm2.TextBoxData;

You send information, usually, in the Form2 constructor. Create a new constructor that has parameters for whatever information you need to send back to form1. To get access to the text box on form2, the best way is to create a public property that gives read access:

Somewhere in form2:

public String TextBoxData {
    get {
        return myTextBox.Text;
    }
}

Now in form1 you'd do something like

Form2 myForm2 = new Form2(parameters go here);
myForm2.ShowDialog();  // force user to interact with form2
String valueFromForm2 = myForm2.TextBoxData;

Thanks :)

Newbie question: what's a constructor? Lol :D

Constructors are methods that are used to instantiate an object. For example:

class Point {
    public int X {get; set;}
    public int Y {get; set;}

    public Point() {  // void constructor
        X = 0;
        Y = 0;
    }

    public Point(int x, int y) {  // constructor with parameters
        X = x;
        Y = x;
    }
}

When we want to create an object, we call the constructor with the new keyword:

Point myPoint1 = new Point(); // Calls the void constructor
Point myPoint2 = new Point(3, 6); // Calls the parameterized constructor

There is a lot more to constructors, but that's the basics.

This article has been dead for over six months. Start a new discussion instead.