Jump to content

MessageBox

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
How do I get Yes or No in a MessageBox instead of Cancel and OK?

#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
Results are constants from the DialogResult class:

* DialogResult.Yes
* DialogResult.No
* DialogResult.Cancel
* DialogResult.Abort
* DialogResult.Ignore
* DialogResult.None
* DialogResult.Retry
* DialogResult.OK

So a message box call sequence could look like:

DialogResult dr = MessageBox.Show("Are you happy now?", 
                      "Mood Test", MessageBoxButtons.YesNo);
switch(dr){
   case DialogResult.Yes: break;

   case DialogResult.No: break;
}

From: http://faculty.junia...ui/csmsgbox.htm