All you have done here in create a new instance of Form1 and then closed that. There is no connection between the Form1 you have open and the new Form1 you created.
You need to pass the reference to Form1 to Form2 when Form2 is created (or at some later point). You can use a property in Form2 to do this.
For example, if both are opened from button clicks in a parent form when the button to create Form2 is clicked the code passes in Form1 to Form2's constructor.
Once you have that reference in Form2 you can call methods on Form1.
This will work, although normal practise is having a button in the form or dialog itself, to close it.
public partial class Form1 : Form
Form Form2; // field inform1 class
// init and show form2
Form2 = new Form();
Form2.Text = "Second form";
private void button1_Click(object sender, EventArgs e)
// in button event handler to close form2
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...