g_johnson
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?
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?
how about FormClosed property for the form?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are looking to close a form could you not just use this.Close(); upon an event?
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?
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");
<-------------------------
}
Any idea what I'm doing wrong?
ASKER
I found that I had to add to initialize components:
//
// form closing
//
this.Closing += new System.ComponentModel.Canc elEventHan dler(this. frmEvent_C losing);
//
// form closing
//
this.Closing += new System.ComponentModel.Canc