重複の可能性:
Winformフォーム新しいフォームを閉じて開く
私のWindowsアプリケーションには、2つの形式があります。form1とform2
form1では、次のハンドラーでボタンのクリックを聞きます。
private void btn1_Click(object sender, EventArgs e)
{
    Form2 updatewindow = new Form2();
    updatewindow.Show();
}
Form2では、ボタンをクリックして最初のフォームであるform1を表示したいので、form2のボタンクリックハンドラーは次のことを行います。
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();
        }
}
問題は、古いフォームを表示したいのですが、代わりに新しいForm1ウィンドウが開いています。
form1フォームform2を更新したい