473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Wh atever)
// User pressed the Save button

- Eric
Mar 15 '08 #1
2 6980
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********@gma il.comwrote in message
news:3d******** *************** ***********@d4g 2000prg.googleg roups.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.Wh atever)
// User pressed the Save button

- Eric
Mar 15 '08 #2
"WP" <mi********@gma il.comwrote in message
news:3d******** *************** ***********@d4g 2000prg.googleg roups.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.Wh atever)
// 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
3696
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
17740
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 Cancel buttons. These buttons have to be on the panels themselves so that they can create the color range from the current settings on the panel and return the result via a delegate to the main dialog form. The problem I have is that the OK...
7
2642
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 my button service in the dialog form, I have: Private Sub btnSave_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSave.Click
2
7543
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 shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
11
2651
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) However, this does not work, and I have to use: if (openFileDialog1->ShowDialog()== System::Windows::Forms::DialogResult::OK)
5
3823
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 confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an extender method. ''' #################################### '''
1
2354
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 (calling form) DeliveryInfo DeliveryFrm = new DeliveryInfo(Convert.ToInt32(this.uniqueIDTextBox.Text)); DialogResult result;
3
3670
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 - "TextField" and "FileChooser". Here is definition of "TextField" <xsd:complexType name="TextField">
7
5586
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 DialogResult.Cancel??? I have overloaded the ShowDialog to accept parameters in the 'Parent' Dialog main Code ...Calling Parent Dialog
0
8394
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
8306
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
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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
5632
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
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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.