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