关闭Windows窗体后如何运行函数? C# [英] How can i run a function after closing a windows form? c#
问题描述
嗨。我在使用VS 2015的c#中使用Windows窗体应用程序项目。
Hi. i work on a windows form application project in c# using VS 2015.
我在表单A中有一个datagridview,我希望在关闭表单B后刷新表单A上的这个数据网格视图。
i have a datagridview in Form A and i want to refresh this datagridview on Form A after closing Form B.
(表格B将通过表格A中的按钮点击打开。)
(Form B will be open by button click in Form A).
我该怎么做?
推荐答案
如果使用
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();
< span lang ="EN-GB"style ="margin:0px"> 其中
RefreshGridView 是刷新网格的函数。
where RefreshGridView is your function that refreshes the grid.
这篇关于关闭Windows窗体后如何运行函数? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!