[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

action upon closing form

Posted on 2006-11-27
5
Medium Priority
?
326 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:g_johnson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:AlexNek
ID: 18023261
how about FormClosed property for the form?
0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 1500 total points
ID: 18023282
Hi you should be able to use the Form.Closed event for the form.  If you are unable to add it through the GUI you can use the delegation given below.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.form.closed.aspx

or with 2005 (.NET 2.0) you would be better using the formclosed event for the form

http://msdn2.microsoft.com/en-us/library/system.windows.forms.form.formclosed.aspx
0
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 18026648
If you are looking to close a form could you not just use this.Close(); upon an event?
0
 
LVL 4

Author Comment

by:g_johnson
ID: 18028868
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?
0
 
LVL 4

Author Comment

by:g_johnson
ID: 18029978
I found that I had to add to initialize components:

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question