MessageBox usage in C #

Source: Internet
Author: User

[Function] <integer> MessageBox (<string text, <string> title, <integer> ntype, messageboxicon );
[Function description] A message box is displayed.
Syntax parameters:
Text <string>, the body of the message box;
Title <string>: the title of the message box;
Ntype <integer> is the type of the message box.
Return Value: <integer>. In the message box, click the button selected when the message is closed.

Messageboxicon: the icon style displayed in the dialog box.

Instance:

MessageBox ("MessageBox message box ");

MessageBox ("message content", "Return Value Confirmation 1", messageboxbuttons. OK, messageboxicon. Question );
MessageBox ("message content", "Return Value Confirmation 1 cancel 2", messageboxbuttons. okcancel, messageboxicon. Asterisk );
MessageBox ("message content", "Return Value termination 3 retry 4 ignore 5", messageboxbuttons. abortretryignore, messageboxicon. Error );
MessageBox ("message content", "Return Value is 6 No 7 cancel 2", messageboxbuttons. yesnocancel, messageboxicon. Exclamation );
MessageBox ("message content", "returned value is 6 No 7", messageboxbuttons. yesno, messageboxicon. Hand );
MessageBox ("message content", "Return Value retry 4 cancel 2", messageboxbuttons. retrycancel, messageboxicon. information );

Get the return value of MessageBox:

First, you must know that the value returned by MessageBox is of the dialogresult type. The returned values may be as follows:

Dialogresult. OK // The value returned after you click "OK ".

Dialogresult. Yes // click "yes" to return the value after the "button"

Dialogresult. No // The value returned after you click "no ".

For example:

Dialogresult DR = MessageBox. Show ("message content", "returned value is 6 No 7", messageboxbuttons. yesno, messageboxicon. Hand );

If (DR = dialogresult. Yes)

{

MessageBox ("click" is "");

}

Else

{

MessageBox ("click" no "");

}

Messageboxbuttons parameter, click to select
Member Name Description:

The abortretryignore message box contains the "Abort", "retry", and "Ignore" buttons.

The OK message box contains the "OK" button.

The okcancel message box contains the "OK" and "cancel" buttons.

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 the "yes", "no", and "cancel" buttons.


Messageboxicon parameter, icon Selection

Member Name Description:

Asterisk the message box contains a symbol consisting of a circle and its lower-case letter I.

Error the message box contains a symbol consisting of a circle with a red background and its white X.

Exclamation the message box contains a symbol consisting of a triangle with a yellow background and an exclamation point.

Hand the message box contains a symbol consisting of a circle with a red background and its white X.

Information the message box contains a symbol consisting of a circle and its lower-case letter I.

The none message box does not contain symbols.

Question the message box contains a symbol consisting of a circle and a question mark.

Stop the message box contains a symbol consisting of a circle with a red background and its white X.

Warning the message box contains a symbol, which is composed of a triangle with a yellow background and an exclamation point in it.

Related Article

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.