Summary of MessageBox usage in C #

Source: Internet
Author: User

MessageBox is often used in programs.

MessageBox. Show () contains a total of 21 overload methods. The common usage is summarized as follows:

 

1. MessageBox. Show ("Hello ~~~~ ");

The simplest way is to display only the prompt information.

 

 

2. MessageBox. Show ("There are something wrong! "," ERROR ");

You can add a title to the message box.

 

 

3. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel) = DialogResult. OK)

{

// Delete

}

This is used when you ask whether to delete it.

 

 

4. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. Question) = DialogResult. OK)

{

// Delete

}

You can add an Icon to MessageBox. net provides common options for icons.

 

 

 

5. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. Question, MessageBoxDefaultButton. Button2) = DialogResult. OK)

{

// Delete

}

The default focus of MessageBox can be changed as follows:

 

 

6. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. Question, MessageBoxDefaultButton. Button2, MessageBoxOptions. RtlReading) = DialogResult. OK)

{

// Delete

}

Reverse display:

 

 

7. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. Question, MessageBoxDefaultButton. Button2, MessageBoxOptions. RightAlign, true) = DialogResult. OK)

{

// Delete

}

Add the Help button:

 

 

8. if (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. Question, queue. Button1, MessageBoxOptions. RtlReading, @"/folder/file.htm ") = DialogResult. OK)

{

// Delete

}

Specify the path of the Help file and click it to open the Help file under this path.

 

 

 

9. // HelpNavigator specifies a constant to indicate the Help File element to be displayed. The Find help file is displayed on the search page.

If (MessageBox. Show ("Delete this user? "," Confirm Message ", MessageBoxButtons. OKCancel, MessageBoxIcon. question, MessageBoxDefaultButton. button1, MessageBoxOptions. rtlReading, @ "/folder/file.htm", HelpNavigator. find) = DialogResult. OK)

{

// Delete

}

 

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.