Introduction:
The function of MessageBox() is to display a message dialog box, which contains a system icon , a set of buttons and a short application-specific message, such as status or error information.
format:
MessageBox.Show(string Text, string Caption, MessageBoxButtons,MessageBoxIcon);
- The first parameter is String type, which means the content in the prompt box ;
- The second parameter is a String type, which represents the title of the prompt box ;
- The third parameter is the button of the prompt box , such as OK, Cancel, etc.;
- The fourth parameter is the icon of the prompt box , such as warning, prompt, question and so on.
Of course, according to personal needs, you can fill in only one of the four parameters, or two or three, according to your needs!
Common code display:
MessageBox.Show("用户名或者密码不能为空");
MessageBox.Show("用户名或者密码不能为空","登录提示");
MessageBox.Show("用户名或者密码不能为空","登录提示",MessageBoxButtons.OKCancel);
MessageBox.Show("用户名或者密码不能为空","登录提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation);
icon:
parameter | meaning |
MB_ICONEXCLAMATION |
An exclamation point appears in the message box |
MB_ICONWARNING |
An exclamation point appears in the message box |
MB_ICONINFORMATION |
An icon consisting of a lowercase letter i in a circle appears in the message box |
MB_ICONASTERISK |
An icon consisting of a lowercase letter i in a circle appears in the message box |
MB_ICONQUESTION |
A question mark icon appears in the message box |
MB_ICONSTOP |
A stop message icon appears in the message box |
MB_ICONERROR |
A stop message icon appears in the message box |
MB_ICONHAND |
A stop message icon appears in the message box |
Button:
Button parameters |
meaning |
MB_OK |
Defaults. There is a confirmation button inside. |
MB_YESNO |
There is yes and no in it. |
MB_ABORTRETRYIGNORE |
There are Abort (abandon), Retry (retry) and Ignore (skip) |
MB_YESNOCANCEL |
The message box contains three buttons: Yes, No and Cancel |
MB_RETRYCANCEL |
There are Retry and Cancel |
MB_OKCANCEL |
The message box contains two buttons: OK and Cancel |
to sum up:
In MessageBox(), the content and title are customized, and there are many kinds of buttons and icons, according to your own needs, I will not list them all here.