The "OK" Cancel dialog box pops up in C #

Source: Internet
Author: User

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

The Abortretryignore message box contains the abort, retry, and Ignore buttons.


The OK message box contains the OK button. Default
The Okcancel message box contains the OK and Cancel buttons. (as shown in the previous example)
The Retrycancel message box contains the retry and Cancel buttons.

The YESNO message box contains the Yes and no buttons.
The Yesnocancel message box contains Yes, no, and Cancel buttons.

For example:

MessageBoxButtons Messbutton = Messageboxbuttons.okcancel;
DialogResult dr = MessageBox.Show ("OK to exit?", "Exit System", Messbutton);
if (dr = = DialogResult.OK)
{
This. Close ();
}

Pop-up OK, cancel the prompt box, if click Confirmation Program exit. Cancel closes the prompt box.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.