473,473 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

why does my dialog act wired when closing the app?

Ajm113
161 New Member
Ok, first off I like to say hi and I am a developer of the Doom3 Scripter project and I wanted to go with C# and Visual Studios for the 2.0 area and I needed some help with both of those things.

Back to my subject:
I am currently working on a dialog that asks you are you sure you want to leave. I have this so far and it works perfectly when I have it as a EventArgs. When I link it to something like Exit in the file menu. Though when it comes to the events in the app itself where the "Form Closing" is on Visual Studios it seems to act wired. Like if you pushed "Yes" it brings up the dialog again and asks you the same question. Then it shuts down. Or if you are "Not Sure" it closes the application right away.

Here is the code for the "File" menu
Expand|Select|Wrap|Line Numbers
  1.         private void Exit(object sender, System.EventArgs e)
  2.         {
  3.             DialogResult dr = System.Windows.Forms.MessageBox.Show("Are You Sure You Want To Exit?", "Exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  4.  
  5.             if (dr == DialogResult.Yes)
  6.             {
  7.                 //close the program
  8.                 Application.Exit();
  9.             }
  10.             else
  11.             {
  12.                 //Cancel
  13.             }
  14.         } 
Its pretty much the same for the FormClosingEventArgs in the private void area that I use.

Can anyone help me?
Jun 6 '07 #1
2 1077
Dököll
2,364 Recognized Expert Top Contributor
Ok, first off I like to say hi and I am a developer of the Doom3 Scripter project and I wanted to go with C# and Visual Studios for the 2.0 area and I needed some help with both of those things.

Back to my subject:
I am currently working on a dialog that asks you are you sure you want to leave. I have this so far and it works perfectly when I have it as a EventArgs. When I link it to something like Exit in the file menu. Though when it comes to the events in the app itself where the "Form Closing" is on Visual Studios it seems to act wired. Like if you pushed "Yes" it brings up the dialog again and asks you the same question. Then it shuts down. Or if you are "Not Sure" it closes the application right away.

Here is the code for the "File" menu
Expand|Select|Wrap|Line Numbers
  1.         private void Exit(object sender, System.EventArgs e)
  2.         {
  3.             DialogResult dr = System.Windows.Forms.MessageBox.Show("Are You Sure You Want To Exit?", "Exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  4.  
  5.             if (dr == DialogResult.Yes)
  6.             {
  7.                 //close the program
  8.                 Application.Exit();
  9.             }
  10.             else
  11.             {
  12.                 //Cancel
  13.             }
  14.         } 
Its pretty much the same for the FormClosingEventArgs in the private void area that I use.

Can anyone help me?
Hello, Ajm113!

I am now getting my feet wet in C#, but it looks like you are not tell the program what to do in order to cancel. May be the reason why you are going in a loop with this...
Jun 7 '07 #2
Ajm113
161 New Member
What do I use to close the dialog then and cencel the closing when the user hits no? I do have a idea on how, becuase I am also a wxPython user and C# seems to none of the less diffrent to me. For the exeption for ";" and brackets in scripts.
Jun 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
1
by: Carmine | last post by:
I'm currently writing a small program that churns on a repetitive task while displaying a progress & cancel modeless dialog. I've been having problems due to threadlocking, and I was wondering if...
4
by: SteveK | last post by:
Hi- I have created a basic login form. If the user enters invalid credentials, I want to display an error. However, when the user presses the Login button, the dialog closes... I'm sure this...
4
by: Hitesh | last post by:
Hi, I am opening an Modal dialog box using the window.Showmodaldialogbox(), and in that window i am having an aspx form with say one ASP.NET Button control. i am doing some operation on the...
17
by: B. Chernick | last post by:
I'm trying to create a web page and I need a javascript function to be called on the load of a particular panel. (The panel is hidden during some but not all postbacks.) The function is bound...
8
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. I have two projects in my application Project A and Project B. And Project A has the reference of Project B. I...
4
by: rdemyan | last post by:
I'm using code from the following web page to open the API Browse Folder dialog http://www.mvps.org/access/api/api0002.htm It all works fine. But if the dialog box is open and the user closes...
5
by: dgleeson3 | last post by:
Hello all I have used the LoginForm1 class in a Visual studio 2005 VB application. Its the standard Username, Pasword request for user input. I was hoping to use property procedures to get...
3
by: Mike Hofer | last post by:
Okay, here's the situation: we want to be able to display ASPX pages in an UpdatePanel. The reasons for this are performance related. The site in development uses *lots* of modal popups from some...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.