关闭对话框更新主窗体... [英] Close dialog update main form...

查看:115
本文介绍了关闭对话框更新主窗体...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有两种形式.主窗体和对话框...

当我在对话框上更改某些设置并关闭时,如何更新主窗体?

I have two forms in my project. Mainform and dialog...

When I change somesetting on dialog and close, how i update main form?

推荐答案

可以通过很多方法来实现.

一种方法是模态显示对话框,然后在关闭对话框时检查对话框中的更改并更新主窗体.

如果窗体是无模式打开的,那么您将要使用事件.让对话框表单根据设置更改引发事件,然后将这些事件挂接到主表单上.然后,在引发事件时,执行更改.
There are a lot of ways that this can be done.

One way is to show the dialog modally and then when it''s closed, check the changes in the dialog and update the main form.

If the form is open modelessly then you would want to use events. Have the dialog form raise events based on settings changing and then hook those events on the main form. Then, when the event is raised, implement the changes.


您可以在对话框中创建一个函数,该函数显示对话框(使用ShowShow方法),然后将布尔值返回给指示用户是否更新了数据.然后在您的主窗体中,而不是调用对话框的ShowDialog方法,而是调用您创建的函数,并在函数返回True时刷新网格.
You could create a function in your dialog that displays the dialog (using it''s ShowDialog method) and then returns a boolean to indicate whether the user updated the data or not. Then in your main form instead of calling the dialog''s ShowDialog method call the function you created and refresh the grid if the function returns True.


这篇关于关闭对话框更新主窗体...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆