Cancel Leave Event when closing

Posted by DiegoMaK on Stack Overflow See other posts from Stack Overflow or by DiegoMaK
Published on 2010-04-19T00:53:09Z Indexed on 2010/04/19 1:03 UTC
Read the original article Hit count: 374

Filed under:
|
|
|
|

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

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();
        }
    }

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
    }

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms