Link to home
Start Free TrialLog in
Avatar of g_johnson
g_johnsonFlag for United States of America

asked on

action upon closing form

I have frmMain, which opens frmEvent from within a timer (f.Show not ShowDialog).

When I close the instance of frmEvent by clicking on the X in the ControlBox, I want to update a database.
I can't find any kind of close event in frmEvents memebers.

How do I do this?
Avatar of AlexNek
AlexNek

how about FormClosed property for the form?
ASKER CERTIFIED SOLUTION
Avatar of Raynard7
Raynard7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of angus_young_acdc
If you are looking to close a form could you not just use this.Close(); upon an event?
Avatar of g_johnson

ASKER

I have tried the following and can't spot what I am doing wrong.  I also tried the "closing" rather than "closed" event.

After build, "Closed" is underlined saying "never used"
public event EventHandler Closed;

This code never executes:
private void frmEvent_Closed(object sender, System.EventArgs e)
{
     MessageBox.Show("Here");
     <----------------------------------------this is where I would like to update a database
}

Any idea what I'm doing wrong?
I found that I had to add to initialize components:

//
//      form closing
//
this.Closing += new System.ComponentModel.CancelEventHandler(this.frmEvent_Closing);