Solved

action upon closing form

Posted on 2006-11-27
5
323 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 500 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

Technology Partners: 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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