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

x
?
Solved

Dialog return values

Posted on 2004-11-11
2
Medium Priority
?
196 Views
Last Modified: 2010-04-15
Hi,

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.
0
Comment
Question by:ba272
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
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.
0
 
LVL 6

Expert Comment

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

Chester.
0

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