Detailed explanation and use of messagebox for C# message box
The message dialog box is displayed using the show method of the messagebox object. The MessageBox object is part of the namespace. Show is a static method, which means that you can use this method without creating an instance based on the MessageBox class object. Moreover, this method can be overloaded, that is, the method can have different parameter list forms.
Return result:DialogResult dr1=(text,caption,buttons,icon,defaultbutton,option);
No value is returned:(text,caption,buttons,icon);
Parameters must be output in the above order
1.Text: Set the prompt text statement in the message dialog box. It must be of String type
2.Caption: Optional parameters, set the title of the message dialog box, must be string type
3. Buttons: optional parameters, set which buttons are displayed in the message dialog box
4. Icon: Optional parameters, set which icon to display in the message dialog box
5. Defaultbutton: optional parameters, set which button in the message dialog box is activated by default
6. Optional parameters, set some special options for the message dialog box, such as text alignment, specifying the reading order, and whether to write messages to the system log
Button enumeration constants and meanings
Ok | |
|
|
|
|
|
|
|
|
|
|
|
|
Icon enumeration constants and meanings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Warning | The symbol is composed of a triangle with a yellow background and one of the exclamation marks. |
The return value of the message dialog box is the member, and the enumeration constants and meanings are as follows
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use:
1、 /* if (flag) { DialogResult diagorel = (this, "Please inpult again,your message is empty!", "Information cue", , ); switch (diagorel) { case : = ""; = ""; break; case : break; } }*/
2. This is the easiest way
if( ( "Are you sure to submit?", "hint", ) == ) { Program running code....... }
Thank you for reading, I hope it can help you. Thank you for your support for this site!