473,588 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ 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 FormClosingEven tArgs in the private void area that I use.

Can anyone help me?
Jun 6 '07 #1
2 1081
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 FormClosingEven tArgs 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
3264
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 with this problem. I am uncertain about what etiquette calls for, but more on that later. My Objective: I am trying to control the _VMWare Desktop_ application
1
4237
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 anyone could give me some advice. Basically when I create the modeless dialog, I'm assuming that C# under the covers will be implicitly creating a new thread for the modeless dialog's message pump. Thus I protect the state determiners with a...
4
5843
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 is normal, but how can I interupt this and keep the dialog alive until I am ready for it to close? Thanks, Steve
4
5502
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 click event of the button control on the server and finally closing the window by using the following statement at the end of the click event of the button: Response.Write("<script language='javascript'>window.close();</script>"); But instead of...
17
6423
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 to the panel in VB as follows: pnlAdd.Attributes.Add("onLoad", "SetupScreenLite()") This is basically how we attach all functions in our projects but this is the first time I've worked with onLoad and the first time I've tried to
8
5458
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 need to display a modeless dialog from the main form which is in Project A and the modeless dialog to be raised is in Project B. After closing the modeless dialog i need to pass a value from modeless dialog to the main form of Project A and also i...
4
2903
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 Access, the system just hangs and Access apparantly cannot close. I have to open the Windows Task Manager and force the closing (and even that takes quite awhile).
5
1590
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 back the user input in the two boxes but its not working out.
3
3869
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 pages, and we don't want to load all that content until it's requested. So, what we want to do is place an IFRAME inside an UpdatePanel and, in the onclick event for the linkbutton or button control, set the SRC so that the content is loaded on...
0
7929
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6634
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2372
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 we have to send another system

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.