<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY style="MARGIN-TOP: 2px; FONT: 8pt Tahoma; MARGIN-LEFT: 2px">
<DIV><FONT size=2>There is an event handler discussion for the close event 
here:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><A 
href="http://www.dotnet247.com/247reference/msgs/19/98033.aspx">http://www.dotnet247.com/247reference/msgs/19/98033.aspx</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Gary Ray - Application Developer<BR>Workforce Information Systems R & 
D<BR>E-Mail <A href="mailto:gray@utah.gov">gray@utah.gov</A><BR><BR>>>> 
chizotz@charter.net 06/17/03 10:53AM >>><BR>How do you exit a Windows 
forms application gracefully?<BR><BR>private void menuItemFileQuit_Click(object 
sender, <BR>System.EventArgs e)<BR>      
{<BR>    DialogResult myResult;<BR>    myResult = 
MessageBox.Show("Are you sure you want to quit <BR>?","Polybags 
Tracking",MessageBoxButtons.YesNo , 
<BR>MessageBoxIcon.Question);<BR>         
if (myResult == DialogResult.Yes)<BR>    {<BR>    
     this.Close();<BR>    
     Application.Exit();<BR>    
}<BR>      }<BR><BR>Which works fine when the user 
plays nice and uses my Quit <BR>menu item. What I'm having trouble figuring out 
is how to <BR>handle when the user clicks on the close 'X' button, or <BR>uses 
the control box or alt-F4 to exit the program. I have <BR>put the 
Application.Exit(); in the formMain_Unload, <BR>formMain_Close, etc events and 
the event never fires. I <BR>can't find anything about this in the help files, 
on the <BR>MS site, or in the two thick books on C# I have. Its <BR>frustrating, 
because in VB this is pretty simple to do.<BR><BR>Any help out 
there?<BR><BR>Thanks,<BR><BR>Ron<BR>_______________________________________________<BR>dba-VB 
mailing list<BR>dba-VB@databaseadvisors.com<BR><A 
href="http://databaseadvisors.com/mailman/listinfo/dba-vb">http://databaseadvisors.com/mailman/listinfo/dba-vb</A><BR><A 
href="http://www.databaseadvisors.com/">http://www.databaseadvisors.com</A><BR><BR></DIV></BODY></HTML>