收盘时取消休假活动 [英] Cancel Leave Event when closing

查看:82
本文介绍了收盘时取消休假活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法,在窗体上的文本框从TX predio_Leave事件被调用。

I have got a textbox on a form with a method being called from the txPredio_Leave event.

我的问题是,它是用户关注的文本框,然后通过单击右上角的小x关闭图标或致电 this.ActiveMdiChild.Close()关闭表单; 或致电

My problem is that is the user has focus on the textbox and then close the form by clicking the little X close icon in the top corner or by calling this.ActiveMdiChild.Close(); or by calling

    private void mnucerrarTodas_Click(object sender, EventArgs e)
    {
        foreach (Form form in this.MdiChildren)
        {
            form.Close();
        }
    }

在TX predio离开执行的方法..然后我需要不EXCUTE当窗体关闭这个方法。

The txPredio leave execute the method.. then i need doesn't excute this method when the form is closing.

我认为一个解决方案可以问请假事件,如果窗体关闭

i have think that one solution could be ask in leave event if form is closing

        private void txPredio_Leave(object sender, EventArgs e)
        {  
            if(!form is closing)//pseudo code
               Check_Load_Predio();
        }

或其他方案可以是

or other solution could be

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
    {   
       //code for cancel the txPredio_Leave event
    }

解决方案<一href="http://stackoverflow.com/questions/2339362/how-to-stop-textbox-leave-event-firing-on-form-close">Here对我来说Doesn't工作。然后,我需要为我的问题的一种解决方案。在此先感谢

Solution Here Doesn´t work for me. Then I need one solution for my problem. Thanks in advance

推荐答案

尝试在的FormClosing 删除离开处理程序

修改:像这样的:

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{   
    txPredio.Leave -= txPredio_Leave;
}

这篇关于收盘时取消休假活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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