We often use the MessageBox in our programs.
MessageBox.Show () has a total of 21 overloaded methods. The common usage is summarized as follows:
1.messagebox.show ("hello~~~~");
The simplest is to display only the prompt information.
2.messagebox.show ("There is something wrong!", "ERROR");
You can add a caption to a message box.
3.if (MessageBox.Show ("Delete this user?", "Confirm Message", messageboxbuttons.okcancel) = = DialogResult.OK)
{
Delete
}
This is used when asking whether or not to delete.
4.if (MessageBox.Show ("Delete this user?", "Confirm Message", messageboxbuttons.okcancel,messageboxicon.question) = = DialogResult.OK)
{
Delete
}
You can add a icon,.net to the MessageBox to provide common icon co-selection.
5.if (MessageBox.Show ("Delete this user?", "Confirm Message", Messageboxbuttons.okcancel, Messageboxicon.question, Messageboxdefaultbutton.button2) = = DialogResult.OK)
{
Delete
}
You can change the default focus of the MessageBox, 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, Messageboxdefaultbutton.button1, messageboxoptions.rtlreading, @ "/folder/file.htm") = = DialogResult.OK)
{
Delete
}
Specify the path to the Help file and click to open the Help file under that path.
9.//helpnavigator specifies a constant to indicate the Help file element to display. The Find Help file opens to 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
}
There are some usages, not too useful here is not introduced, interested friends can refer to the following: MSDN's MessageBox class.
MessageBox usage Daquan in C #