473,320 Members | 1,799 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,320 software developers and data experts.

what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?

what do you have to do in a C# dialog so that it returns to ShowDialog as
DialogResult.OK ?
Nov 16 '05 #1
5 3677
Daniel,

Before the dialog is closed, set the DialogResult property to
DialogResult.OK.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel" <so*******************@yahoo.com> wrote in message
news:el**************@TK2MSFTNGP15.phx.gbl...
what do you have to do in a C# dialog so that it returns to ShowDialog as
DialogResult.OK ?

Nov 16 '05 #2
Hi
Actually, setting the DialogProperty will close the dialog. The other
approach would be to set the OK button DialogRestultProperty to
DialogResult.OK. In this case your don't have to do anything. When the user
clicks on the button the framework will set dialog's DialogResult for you
thus, close the dialog.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...
Daniel,

Before the dialog is closed, set the DialogResult property to
DialogResult.OK.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel" <so*******************@yahoo.com> wrote in message
news:el**************@TK2MSFTNGP15.phx.gbl...
what do you have to do in a C# dialog so that it returns to ShowDialog as
DialogResult.OK ?


Nov 16 '05 #3
For accessibility compliance you may also want to provide a Cancel button
that has a DialogResult property of DialogResult.Cancel, set the dialog Form's
AcceptButton to your Ok button, and the CancelButton to the cancel button.

Then you have all of your bases covered so that users can quickly navigate
and consume your dialog... (PS: Add some Alt+Key accessors to your
buttons, and if you accept user input to your Labels)...
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
Hi
Actually, setting the DialogProperty will close the dialog. The other approach
would be to set the OK button DialogRestultProperty to DialogResult.OK. In
this case your don't have to do anything. When the user clicks on the button
the framework will set dialog's DialogResult for you thus, close the dialog.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...
Daniel,

Before the dialog is closed, set the DialogResult property to
DialogResult.OK.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel" <so*******************@yahoo.com> wrote in message
news:el**************@TK2MSFTNGP15.phx.gbl...
what do you have to do in a C# dialog so that it returns to ShowDialog as
DialogResult.OK ?



Nov 16 '05 #4
Stoitcho Goutsev (100) [C# MVP] wrote:
Hi
Actually, setting the DialogProperty will close the dialog. The other
approach would be to set the OK button DialogRestultProperty to
DialogResult.OK. In this case your don't have to do anything. When the user
clicks on the button the framework will set dialog's DialogResult for you
thus, close the dialog.

Hmm, Im still trying to decide on the best methodology here.
Whether to:
a) in the ok button click event set this.DialogResult = DialogResult.Ok
or
b) set DialogResult property of button to Ok

The "different" thing about option b is that you expect the ok buttons
click event to have code in it and when it doesnt, you have to actively
remember that you have a dialogresult property. (New to .NET IIRC).

Having said that, I use option b.

:)
JB
Nov 16 '05 #5
Well, that's why you have options. Whatever suits your needs better. But
knowing that Button.DialogResult exsists there should be no problem figuring
out why the button closes the form.

--

Stoitcho Goutsev (100) [C# MVP]
"The Last Gunslinger" <jb******@yahoo.com> wrote in message
news:%H******************@news-server.bigpond.net.au...
Stoitcho Goutsev (100) [C# MVP] wrote:
Hi
Actually, setting the DialogProperty will close the dialog. The other
approach would be to set the OK button DialogRestultProperty to
DialogResult.OK. In this case your don't have to do anything. When the
user clicks on the button the framework will set dialog's DialogResult
for you thus, close the dialog.

Hmm, Im still trying to decide on the best methodology here.
Whether to:
a) in the ok button click event set this.DialogResult = DialogResult.Ok
or
b) set DialogResult property of button to Ok

The "different" thing about option b is that you expect the ok buttons
click event to have code in it and when it doesnt, you have to actively
remember that you have a dialogresult property. (New to .NET IIRC).

Having said that, I use option b.

:)
JB

Nov 16 '05 #6

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

Similar topics

2
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
23
by: George | last post by:
Is there a way to customize the open file common dialog? I am trying to modify the button text so I can create a delete file common dialog. I need the same functionality of the open file common...
1
by: steve bull | last post by:
I created a dialog box which runs fine when I call Show() but gives the following unhandled exception when I call ShowDialog(). It crashes when exiting from the menu item callback that invoked it. ...
4
by: ronenk | last post by:
I have this code to load an authentication form once my app is loaded. I want the authentication form to be closed if a user is authenticated successfully and to give the option to close app on his...
5
by: pswulius | last post by:
Hey everyone, for reasons I can't explain quickly, I'm developing a completely custom OK/OK_CANCEL dialog, though I think many people would benifit from this knowledge. I basically need to...
9
by: Ale K. | last post by:
What's the best way to make a form return a value.... i want to try to avoid using module variables for doing this... Thanks. Alex.
10
by: GJP | last post by:
Hello. Ive been asked to make my own notepade for college assignment. All ig going well, but i cant get the save to work. I can get Save a (shows dialog box), i can get it to just save too,...
18
by: Dusty Hackney | last post by:
Hello, I am programming in Visual Basic .NET. I have seen examples of creating a login form to use for users to type in their username and password, but I want to accomplish the same thing with...
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:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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....

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.