Possible Duplicate:
Winform Forms Closing and opening a new form
In my windows application I have two forms; form1 and form2
In form1 I listen to a button click with the following handler,
private void btn1_Click(object sender, EventArgs e)
{
Form2 updatewindow = new Form2();
updatewindow.Show();
}
In Form2 I want to click on a button and show the first form, form1, so the button click handler in form2 does the following
private void btn2_Click(object sender, EventArgs e)
{
try
{
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "codedata.xml");
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNodeList nodelist = doc.SelectNodes("Root/data[Sno='" + getsnofromform1 + "']");
nodelist[0].ChildNodes[2].InnerText = txt_productcodeupdate.Text;
nodelist[0].ChildNodes[3].InnerText = txt_productnameupdate.Text;
nodelist[0].ChildNodes[4].InnerText = txt_brandcodeupdate.Text;
nodelist[0].ChildNodes[5].InnerText = txt_brandnameupdate.Text;
doc.Save(path);
MessageBox.Show("Selected Record Updated Successfully");
}
catch
{
}
finally
{
//txt_sno.Text = "";
// txt_companycode.Text = "";
txt_productcodeupdate.Text = "";
txt_productnameupdate.Text = "";
txt_brandcodeupdate.Text = "";
txt_brandnameupdate.Text = "";
BarcodeCount form1 = new BarcodeCount();
form1.BringToFront();
form1.Invalidate();
Application.OpenForms["BarcodeCount"].Refresh();
this.Close();
}
}
The problem is I want to display the old form, but instead a new Form1 window is opening.
i want to refresh the form1 form form2