Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping the "X" button to close a form ...

Status
Not open for further replies.

sacheson

Programmer
Mar 30, 2000
55
US
Hey,

Can anyone help me in trapping the event of using the "X" to close a form?

I'm trying to handle a child form closing in two different ways (depending on how it was initialized by the parent form). I have all of the code working with the exception of closing the form by pressing the "X".

I can just disable it, but if I could deal with this more elegantly, than I'd prefer to do that ...

Thanks
SAcheson.
 
Hey,

Have you tried overriding the "X" close button?

Code:
protected override void OnClosing(CancelEventArgs e)
{
    //
    // Your code here
    //

    base.OnClosing(e);
}

Thank you,
karmafree.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top