What buttons need to be displayed in a message box where OK and cancel are displayed
MessageBoxButtons Messbutton = Messageboxbuttons.okcancel;
"Are you sure you want to exit?" "Is the display information for the dialog box," Exit System "is the title of the dialog box
By default, such as MessageBox.Show ("Are you sure you want to exit?") ") displays only one OK button.
DialogResult dr = MessageBox.Show ("OK to exit?", "Exit System", Messbutton);
if (dr = = DialogResult.OK)//If Click "OK" button
{
......
}
else//If you click the "Cancel" button
{
......
}
MessageBoxButtons specifies several constants to define which buttons will appear on MessageBox (from MSDN)
MessageBoxButtons Member:
Description of Member name
Abortretryignore |
The message box contains the abort, retry, and Ignore buttons. |
Ok |
The message box contains the OK button. Default |
Okcancel |
The message box contains the OK and Cancel buttons. (as shown in the previous example) |
Retrycancel |
The message box contains the retry and Cancel buttons. |
Yesno |
The message box contains the Yes and no buttons. |
Yesnocancel |
The message box contains Yes, no, and Cancel buttons. |