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 - private void Exit(object sender, System.EventArgs e)
-
{
-
DialogResult dr = System.Windows.Forms.MessageBox.Show("Are You Sure You Want To Exit?", "Exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
-
-
if (dr == DialogResult.Yes)
-
{
-
//close the program
-
Application.Exit();
-
}
-
else
-
{
-
//Cancel
-
}
-
}
Its pretty much the same for the FormClosingEven tArgs in the private void area that I use.
Can anyone help me?
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 - private void Exit(object sender, System.EventArgs e)
-
{
-
DialogResult dr = System.Windows.Forms.MessageBox.Show("Are You Sure You Want To Exit?", "Exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
-
-
if (dr == DialogResult.Yes)
-
{
-
//close the program
-
Application.Exit();
-
}
-
else
-
{
-
//Cancel
-
}
-
}
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...
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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
|
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...
|
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
| |
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...
|
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).
|
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.
|
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...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |