[Solved] How to call a form when there are 3 forms in a project and data Transfer between the forms in C#?


Can you explain why you don’t want to touch your Program.cs file? This is exactly where you change the start-up form.

Change the:

Application.Run(new Form1());

to:

Application.Run(new Form4());

Secondly, you can set the filters on Open- and SaveFileDialog using the Filter property. Set it to a value like this:

XML Files|*.xml

Or for text:

Text Files|*.txt

Edited to add:

To do this from another form:

class Form1 {
  Form2 form2;

  void Form1_Load(object sender, EventArgs e) {
    form2 = new Form2();
  }

  void rdb1_CheckedChanged(object sender, EventArgs e) {
    if (rdb1.Checked) 
      form2.openFileDialog1.Filter = "XML Files|*.xml";
    else
      form2.openFileDialog1.Filter = "Text Files|*.txt";
  }
}

Make sure you have set the Modifiers property of the openFileDialog1 on the Form2 designer to “Public” or “Internal” to allow access to it from outside the class itself.

2

solved How to call a form when there are 3 forms in a project and data Transfer between the forms in C#?