[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Dialog return values

Posted on 2004-11-11
Medium Priority
Last Modified: 2010-04-15

I created a modal dialog with OK and Cancel buttons.  Inside the dialog, I call the Close() function to close the dialog.  But when I inspect the return value (see code below), it comes back as Cancel, even though I clicked on the OK button.

Password pwDlg = new Password();
System.Windows.Forms.DialogResult reply = pwDlg.ShowDialog(this);
if ( reply == System.Windows.Forms.DialogResult.OK )
    // do something

By this I mean that the value of the reply variable is "Cancel".

Am I missing something?  Should I be associating a button object with the some property so this built-in functionality works?

Thanks for the help.
Question by:ba272
  • 2

Accepted Solution

Chester_M_Ragel earned 2000 total points
ID: 12562482
In the Dialog from(Password form), select the Kk button and set its DialogResult property to Ok. Like that for Cancel button set its DialogResult property to Cancel.

Expert Comment

ID: 12562486
Oops.. not KK, Ok. Sorry for that...


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question