且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

关闭Windows窗体后如何运行函数? C#

更新时间:2023-12-06 16:53:40

如果使用
ShowDialog 显示表单,请检查:

If the form is displayed using ShowDialog, then check this:

  
var
b =
new FormB();

  
b.ShowDialog();

   b.ShowDialog();

  
RefreshGridView();

   RefreshGridView();

 

如果是
显示

  
var
b =
new FormB();

  
b.FormClosed + =(s,a)=> RefreshGridView();

   b.FormClosed += ( s, a ) => RefreshGridView();

  
b.Show();

   b.Show();

 

其中
RefreshGridView 是刷新网格的函数。

where RefreshGridView is your function that refreshes the grid.