I have 3 forms. Form 1 has information inserted into Form 2. After clicking a button on Form 2 to get to Form 3; on Form 3 I pull data and put it on Form 2. The problem with this is that I don’t know how to get a single instance of Form 2 so that I can keep the data from Form 1 after pulling data from Form 3. This is a WinForms application. Any help would be much appreciated. I have looked into the Singleton way of doing it but everything I research seems too confusing to follow. Thanks!
3
Forms are objects, so you can pass them into the constructor of each other form:
Class Form2{
Form form1;
Form Form2(Form form1){ // Constructor
this.form1 = form1;
}
}
Now, you have a reference to the Form1 object in a field of Form2. If you need information, you use Form1.information
0