Beginner Dialog Question

M

markliam

I have a dialog box that asks for user input in 3 textboxes and has 2
buttons: Ok & Cancel.

If the user input is validated, the box should return
DialogResult.OK. If the user input isn't validated, it should display
a message and return nothing at all, keeping the dialog box visible
until the input is validated or the user presses the cancel button.

The problem is that I can't choose between "return DialogResult.OK" or
just "return" (to keep the dialog visible) because they're different
return types.

I can think of a few ways to work around it, including validating the
input in the main form and re-displaying the dialog box if it fails,
but I'm wondering what the standard method of handling something like
this?
 
N

Norapinephrine

I have a dialog box that asks for user input in 3 textboxes and has 2
buttons: Ok & Cancel.

If the user input is validated, the box should return
DialogResult.OK. If the user input isn't validated, it should display
a message and return nothing at all, keeping the dialog box visible
until the input is validated or the user presses the cancel button.

The problem is that I can't choose between "return DialogResult.OK" or
just "return" (to keep the dialog visible) because they're different
return types.

I can think of a few ways to work around it, including validating the
input in the main form and re-displaying the dialog box if it fails,
but I'm wondering what the standard method of handling something like
this?

In my experience, everyone has something to complain about for all
dialogs.

But in general, dialogs within an application should all behave the
same way.

My recommendation is to 1) choose the behaviour that fits in with the
rest of the dialogs in the application and then 2) get user feedback
from a prototype and update the behaviour accordingly.
 
C

Chris Shepherd

I have a dialog box that asks for user input in 3 textboxes and has 2
buttons: Ok & Cancel.

If the user input is validated, the box should return
DialogResult.OK. If the user input isn't validated, it should display
a message and return nothing at all, keeping the dialog box visible
until the input is validated or the user presses the cancel button.

The problem is that I can't choose between "return DialogResult.OK" or
just "return" (to keep the dialog visible) because they're different
return types.

You can use DialogResult.None for exactly that -- setting it means that
it will remain visible.
I can think of a few ways to work around it, including validating the
input in the main form and re-displaying the dialog box if it fails,
but I'm wondering what the standard method of handling something like
this?

IMO there are a number of valid reasons to keep your validation inside
the dialog, provided it has all the information it needs to accurately
validate the input.


Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top