【发布时间】:2017-06-03 13:57:20
【问题描述】:
您好,我有form1 和form2
private void form1_Load(object sender, EventArgs e)
{
//codes to display db
}
然后我使用form2.ShowDialog(); 打开表单,因为我不想要多个窗口
然后在我的 form2 中我必须删除一些东西,所以 form1 必须更新显示。
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//codes to delete
form2_Load(sender, e); //so the form2 will reload
}
首先我必须先打开form1,然后才能打开form2。我如何更新/刷新form1,同时仍处于 form2 中?
编辑:
我唯一想在form1 中刷新的是dataGridView
【问题讨论】:
-
不打开form1是否可以打开form2
-
顺便说一句,不要直接调用
form2_Load(sender, e)之类的事件处理程序。你应该把这些东西写在一个函数中,然后在form2_Load和dataGridView1_CellContentClick中调用那个函数 -
@un-lucky 没有。 form1 必须先打开。
-
不要考虑刷新控件:刷新数据源。然后,如果他们使用相同的数据源,则无需刷新