MessageBox.Show 方法使用:

MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

MessageBoxIcon 值之一,它指定在消息框中显示哪个图

MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。

MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。若要使用默认值,请传入 0

MessageBox("消息内容", "返回值 确定1",MessageBoxButtons.OK,MessageBoxIcon.Question);
MessageBox("
消息内容",, "返回值 确定1 取消2",MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
MessageBox("
消息内容", "返回值 终止3 重试4 忽略5",MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
MessageBox("
消息内容", "返回值 6 7 取消2",MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
MessageBox("
消息内容", "返回值 6 7",MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
MessageBox("
消息内容", "返回值 重试4 取消2",MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

1.

MessageBox.Show("没有选中清空对象,请选择!");

 MessageBox.Show <wbr>方法使用:

 

2.

MessageBox.Show("没有选中清空对象,请选择!""清空");

 MessageBox.Show <wbr>方法使用:

3.

 MessageBox.Show("没有选中!""清空"MessageBoxButtons.OK, MessageBoxIcon.Question);

 MessageBox.Show <wbr>方法使用:

4.

MessageBox.Show("确定清空吗?""提示"MessageBoxButtons.OKCancel) == DialogResult.OK;

 MessageBox.Show <wbr>方法使用:

5.

MessageBox.Show("没有选中!""清空"MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

 MessageBox.Show <wbr>方法使用:

6.

MessageBox.Show("没有选中!""清空"MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;

 MessageBox.Show <wbr>方法使用:

7.

MessageBox.Show("没有选中!""清空"MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button3);

 MessageBox.Show <wbr>方法使用:

 

  

1.     1个参数。

 MessageBox.Show(string text);

//     显示具有指定文本的消息框。

// 参数:text:     要在消息框中显示的文本。

// 返回结果:     System.Windows.Forms.DialogResult 值之一。
 

2.     2个参数。

MessageBox.Show(string text, string caption);

//     显示具有指定文本和标题的消息框。

// 参数:

//   text:      要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

// 返回结果:      System.Windows.Forms.DialogResult 值之一。
 

3.     3个参数。

 MessageBox.Show(string text, string caption, MessageBoxButtons buttons);

//     显示具有指定文本、标题和按钮的消息框。

// 参数:

//   text:      要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

//   buttons:     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常:    

//System.ComponentModel.InvalidEnumArgumentException:     指定的 buttons 参数不是 System.Windows.Forms.MessageBoxButtons 的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示 System.Windows.Forms.MessageBox。这是由 System.Windows.Forms.SystemInformation.UserInteractive 属性指定的。

 

4.     4个参数。

MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);

//     显示具有指定文本、标题、按钮和图标的消息框。

// 参数:

//   text:     要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

//   buttons:     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

//   icon:     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常:

//   System.ComponentModel.InvalidEnumArgumentException:     指定的 buttons 参数不是 System.Windows.Forms.MessageBoxButtons 的成员。- - 指定的 icon24参数不是 System.Windows.Forms.MessageBoxIcon 的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示 System.Windows.Forms.MessageBox。这是由 System.Windows.Forms.SystemInformation.UserInteractive属性指定的。
         
5.     5个参数。 

MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);

//     显示具有指定文本、标题、按钮、图标和默认按钮的消息框。

// 参数:

//   text:      要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

//   buttons:     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

//   icon:     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。

//   default Button:     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常

//   System.ComponentModel.InvalidEnumArgumentException:     buttons 不是 System.Windows.Forms.MessageBoxButtons 的成员。- - icon 不是 System.Windows.Forms.MessageBoxIcon的成员。- - defaultButton 不是 System.Windows.Forms.MessageBoxDefaultButton 的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示 System.Windows.Forms.MessageBox。这是由 System.Windows.Forms.SystemInformation.UserInteractive属性指定的。

 

6.     6个参数。

MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,MessageBoxDefaultButton defaultButton, MessageBoxOptions options);

//     显示具有指定文本、标题、按钮、图标、默认按钮和选项的消息框。

// 参数:

//   text:      要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本

//   buttons:    System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

//   icon:     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。

//   defaultButton:     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。

//   options:     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。若要使用默认值,请传入0

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常:

//   System.ComponentModel.InvalidEnumArgumentException:     buttons 不是 System.Windows.Forms.MessageBoxButtons 的成员。- - icon 不是 System.Windows.Forms.MessageBoxIcon的成员。- - 指定的 defaultButton 不是 System.Windows.Forms.MessageBoxDefaultButton的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示 System.Windows.Forms.MessageBox。这是由System.Windows.Forms.SystemInformation.UserInteractive属性指定的。

//   System.ArgumentException:     options 同时指定了System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly System.Windows.Forms.MessageBoxOptions.ServiceNotification- - buttons42指定了无效的System.Windows.Forms.MessageBoxButtons 组合。
 

7.     7个参数一。

MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton);

//     显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和帮助按钮的消息框。

// 参数:

//   text:      要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

//   buttons:     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

//   icon:     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。

//   defaultButton:     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。

//   options:     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。若要使用默认值,请传入0

//   helpButton:     如果显示帮助按钮,则为 true;否则为 false。默认为 false

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常:34        

//   System.ComponentModel.InvalidEnumArgumentException:     buttons 不是 System.Windows.Forms.MessageBoxButtons 的成员。- - icon 不是 System.Windows.Forms.MessageBoxIcon的成员。- - 指定的 defaultButton 不是 System.Windows.Forms.MessageBoxDefaultButton的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示 System.Windows.Forms.MessageBox。这是由System.Windows.Forms.SystemInformation.UserInteractive属性指定的。

//   System.ArgumentException:     options 同时指定了System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly System.Windows.Forms.MessageBoxOptions.ServiceNotification- - buttons指定了无效的 System.Windows.Forms.MessageBoxButtons 组合。

     

8.  7个参数二

MessageBox.Show(string text, string caption, MessageBoxButtons buttons,MessageBoxIcon icon, MessageBoxDefaultButton defaultButton,MessageBoxOptions options, string helpFilePath);

//     使用指定的帮助文件显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和帮助按钮的消息框。

// 参数:

//   text:     要在消息框中显示的文本。

//   caption:     要在消息框的标题栏中显示的文本。

//   buttons:     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。

//   icon:     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。

//   defaultButton:     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。

//   options:     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。若要使用默认值,请传入0

//   helpFilePath:     用户单击帮助按钮时显示的帮助文件的路径和名称。

// 返回结果:     System.Windows.Forms.DialogResult 值之一。

// 异常:

//   System.ComponentModel.InvalidEnumArgumentException:     buttons 不是 System.Windows.Forms.MessageBoxButtons 的成员。- - icon 不是System.Windows.Forms.MessageBoxIcon的成员。- - 指定的 defaultButton 不是System.Windows.Forms.MessageBoxDefaultButton的成员。

//   System.InvalidOperationException:     试图在运行模式不是用户交互模式的进程中显示System.Windows.Forms.MessageBox。这是由System.Windows.Forms.SystemInformation.UserInteractive属性指定的。

//   System.ArgumentException:     options 同时指定了System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly System.Windows.Forms.MessageBoxOptions.ServiceNotification- - buttons指定了无效的 System.Windows.Forms.MessageBoxButtons 组合。   

转载于:https://www.cnblogs.com/zhaosaiblogs/p/4972715.html

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值