表格之间的反馈 [英] Feedback between Forms

查看:150
本文介绍了表格之间的反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(2)
谢谢,它现在可以根据您的好评(answer)起作用.


(1)
我正在编写Windows窗体应用程序.
单击主窗体(窗体A)上的按钮(按钮A)时,我从主窗体(窗体A)创建了一个新窗体(窗体B).

问题是:

(2)
Thanks, it works now by according to your great comments(answer).


(1)
Hi, I am writing a Windows Form application.
When clicking a button (button A) on Main form (form A), I create a New form (form B) from Main form (form A).

The question is:
How can form A know form B is closed, so that form A can automatically do some process?

推荐答案

让表单A订阅FormBFormClosing 事件:

示例:

Have Form A subscribe to FormClosing event of FormB:

Example:

public partial class FormA : Form
{
    FormB b;
    public FormA()
    {
        InitializeComponent();
        b = new FormB();
        b.FormClosed += new FormClosedEventHandler(b_FormClosed);
        b.Show();
    }
    void b_FormClosed(object sender, FormClosedEventArgs e)
    {
        MessageBox.Show("Form B Has now closed");
    }
}


是的,如果它符合您的要求,则可以使用上面的方法,但是如果表单A中没有创建表单B,则可以使用自定义事件来捕获B形式的close方法.
yes you can use the above method if it matches to your requirement , but if the form B is not created with in the form A you can use custom event to catch the B forms close method .


这篇关于表格之间的反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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