我有一个名为btnA的按钮的窗体A和一个datagrid。
当我单击此按钮时,将打开另一个具有按钮btnB的表格B。当我单击btnB时,我需要关闭表格B并刷新表格A。如何实现此目的?

谢谢。

最佳答案

创建FormB时,将引用传递给FormA

class FormB : Form
{
    FormB(FormA parent)
    {
        this.Parent = parent;
    }
    ...

    protected void btnB_Click(object sender, EventArgs e)
    {
       parent.RefreshGrid();
       this.Close();
    }
}


然后单击butB,可以关闭formB并访问formA进行刷新。

09-25 17:15