473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Extending DialogResult or?

WP
Hello, I making and Windows Forms program and I have a dialog with two
buttons. I have set the DialogResult property for these buttons to
DialogResult.OK and DialogResult.No, respectively (however, these
buttons are not labelled "OK" and "No"). Settting this property is
very convenient, I don't need to write any code determining what
should happen when one of these buttons is clicked. Anyway, now I need
to add a third button and I guess I could set its DialogResult
property to some value (just not DialogResult.OK or DialogResult.No)
but one thing that bothers me is that these property values (OK, No,
whatever) doesn't really tranlaste well to what the buttons actually
mean for this particular dialog. I want to know if I can "extend"
DialogResult with some new constants? Another approach would be, I
guess is to introduce a new property MyDialogResult and have the user
check that after displaying the dialog instead of checking the
returned DialogResult. Then I could continue to use DialogResult for
my buttons and get click handling "for free".
What do you suggest here?

What I'm trying to get away from is this:
DialogResult res = dlg.ShowDialog(this);

if (res == DialogResult.OK)
// User pressed the play button
else if (res == DialogResult.No)
// User pressed the stop button
else if (res == DialogResult.Whatever)
// User pressed the Save button

- Eric
Mar 15 '08 #1
2 6945
You can only return a DialogResult value. The preferred method your case
would be to return OK for all buttons except for the cancel and provide a
property in which you will store the result you really want to communicate.

Extending DialogResult is impossible because you cannot inherit from an
enum.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"WP" <mi********@gmail.comwrote in message
news:3d**********************************@d4g2000p rg.googlegroups.com...
Hello, I making and Windows Forms program and I have a dialog with two
buttons. I have set the DialogResult property for these buttons to
DialogResult.OK and DialogResult.No, respectively (however, these
buttons are not labelled "OK" and "No"). Settting this property is
very convenient, I don't need to write any code determining what
should happen when one of these buttons is clicked. Anyway, now I need
to add a third button and I guess I could set its DialogResult
property to some value (just not DialogResult.OK or DialogResult.No)
but one thing that bothers me is that these property values (OK, No,
whatever) doesn't really tranlaste well to what the buttons actually
mean for this particular dialog. I want to know if I can "extend"
DialogResult with some new constants? Another approach would be, I
guess is to introduce a new property MyDialogResult and have the user
check that after displaying the dialog instead of checking the
returned DialogResult. Then I could continue to use DialogResult for
my buttons and get click handling "for free".
What do you suggest here?

What I'm trying to get away from is this:
DialogResult res = dlg.ShowDialog(this);

if (res == DialogResult.OK)
// User pressed the play button
else if (res == DialogResult.No)
// User pressed the stop button
else if (res == DialogResult.Whatever)
// User pressed the Save button

- Eric
Mar 15 '08 #2
"WP" <mi********@gmail.comwrote in message
news:3d**********************************@d4g2000p rg.googlegroups.com...
Hello, I making and Windows Forms program and I have a dialog with two
buttons. I have set the DialogResult property for these buttons to
DialogResult.OK and DialogResult.No, respectively (however, these
buttons are not labelled "OK" and "No"). Settting this property is
very convenient, I don't need to write any code determining what
should happen when one of these buttons is clicked. Anyway, now I need
to add a third button and I guess I could set its DialogResult
property to some value (just not DialogResult.OK or DialogResult.No)
but one thing that bothers me is that these property values (OK, No,
whatever) doesn't really tranlaste well to what the buttons actually
mean for this particular dialog. I want to know if I can "extend"
DialogResult with some new constants? Another approach would be, I
guess is to introduce a new property MyDialogResult and have the user
check that after displaying the dialog instead of checking the
returned DialogResult. Then I could continue to use DialogResult for
my buttons and get click handling "for free".
What do you suggest here?

What I'm trying to get away from is this:
DialogResult res = dlg.ShowDialog(this);

if (res == DialogResult.OK)
// User pressed the play button
else if (res == DialogResult.No)
// User pressed the stop button
else if (res == DialogResult.Whatever)
// User pressed the Save button

- Eric
I've handled this by setting a property in the dialog and reading it from
the calling form before disposing of the dialog, which you mention in your
post. It gives you possibilities.

RobinS.
GoldMail.com

Mar 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
2
by: steve bull | last post by:
I have built what I think should be a dialog box. It contains 4 tabbed panes for generating a range of colors. Each tabbed pane consists of a panel with all the widgets on them including the OK and...
7
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In...
2
by: dm1608 | last post by:
I'm opening my own form and doing something like: If dlgDirectory.ShowDialog() = DialogResult.OK Then .... End If When I compile the project, I can a warning for the line saying: Access of...
11
by: rk | last post by:
According to the docs, I would expect to check the result of an OpenFileDialog in a VS 2005 CLR Windows Forms application this way: if (openFileDialog1->ShowDialog()== DialogResult::OK) ...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
1
by: Bill Cart | last post by:
I am trying to work with 2 forms. If I set the ModalResult of a button on the 2nd form it works OK. If I try to assign the result and then return it does not return the value I set. 1st Form...
3
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to solve is this: I have two complex types -...
7
by: Masterfrier | last post by:
Hi there! in my app, i open a Dialog, in this dialog i use the FileOpenDialog, when i click on 'Ok' or 'Cancel' in my FileOpenDialog, it automatically closes the parent dialog, with a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.