C# MessageBox (消息提示框)使用详解
若只需要显示消息,不需要根据点击按钮决定下一步干啥,则直接使用即可,如:
MessageBox.Show(text, caption, buttons, icon);
若不仅需要显示消息,还需要根据点击的按钮决定下一步干啥,需要使用对话框的返回结果,一般使用如下代码:
if(MessageBox.Show("参数错误", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { //用户点击Yes } else { //用户点击No }
MessageBoxButtons(按钮)各个成员对应的样式
- OK

- OKCancel
-

-
RetryCancel
-

-
AbortRetryIgnore
-

-
YesNo
-

- YesNoCancel
-

MessageBoxIcon(图标)各个成员对应的样式
- None (没有图标)
- Information

-
Error

- Warning

- Question
-


浙公网安备 33010602011771号