Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / November 2006

Tip: Looking for answers? Try searching our database.

FormClosing event doesn't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
archuleta37 - 08 Nov 2006 19:53 GMT
I'm trying to make the FormClosing event work but nothing is happening. I
have a simple forms app with one form. When I click the X in the top right
corner it seems the Formclosing event is not firing. I first tried to run my
own messagebox, then copied code from
http://msdn2.microsoft.com/en-US/library/system.windows.forms.form.formclosing.aspx and it's not working. Is there something else I need to do?

private void frm2085_FormClosing(Object sender, FormClosingEventArgs e)
       {
           System.Text.StringBuilder messageBoxCS = new
System.Text.StringBuilder();
           messageBoxCS.AppendFormat("{0} = {1}", "CloseReason",
e.CloseReason);
           messageBoxCS.AppendLine();
           messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel);
           messageBoxCS.AppendLine();
           MessageBox.Show(messageBoxCS.ToString(), "FormClosing Event");
           //MessageBox.Show("close event fired");
           //Cleanup(true, true);
       }
Chris Dunaway - 08 Nov 2006 22:33 GMT
> I'm trying to make the FormClosing event work but nothing is happening. I
> have a simple forms app with one form. When I click the X in the top right
[quoted text clipped - 15 lines]
>             //Cleanup(true, true);
>         }

Have you wired up the FormClosing event of your form to this method?
Open the form designer and then click on the form.  In the Properties
Windows, click the little lightning bolt icon.  Then find the
FormClosing event.  Is your method selected there?  If not select it.
Then it should work.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.