How to use MessageBox in C #

Source: Internet
Author: User

Displays a message box. Msdn MessageBox.Show Method

1,

When you want to display a button like Figure 3 and you want to get a different response when you click a different button, you can add one after MessageBoxButtons. (should be in English point, here in order to eye-catching, in Chinese instead) you can see a few buttons below the cue box to choose the different options, the following figure:

if (MessageBox.Show ("Show Message", "title", messageboxbuttons.yesnocancel) = = Dialogresult.yes)

{

Click Yes to do the appropriate processing

}

The return value for MessageBox.Show () is yes, no, OK, or cancel, and you need to set the selection button that it can display in the show () method. That is, clicking a different button returns the same value.

EG:

When MessageBox () is used in C #, the pop-up of the dialog box is usually implemented using the MessageBox Show method, the namespace System.Windows.Forms

application Example:

DialogResult r1 = MessageBox.Show ("Display cue message", "title", Messageboxbuttons.yesnocancel, messageboxicon.question);

if (R1. ToString () = = "Yes")

{MessageBox.Show ("Yes"); }

if (R1. ToString (). Equals ("No"))

{MessageBox.Show ("No");}

if (R1. ToString (). Equals ("Cancel"))

{MessageBox.Show ("Cancel"); }

Display effect:

Click Yes to eject Yes, click No, Pop No, click Cancel to eject Cancel.

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.