博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#中MessageBox.Show()方法详解
阅读量:6941 次
发布时间:2019-06-27

本文共 6101 字,大约阅读时间需要 20 分钟。

1.

// 摘要:

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

//

// 参数:

// text:

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

//

// 返回结果:

// System.Windows.Forms.DialogResult 值之一。

public static DialogResult Show(string text);

 

        例子:MessageBox.Show("内容");

2.

// 摘要:

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

//

// 参数:

// text:

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

//

// caption:

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

//

// 返回结果:

// System.Windows.Forms.DialogResult 值之一。

public static DialogResult Show(string text, string caption);

 

    例子:MessageBox.Show("内容","标题");

3.

// 摘要:

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

//

// 参数:

// 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

// 属性指定的。

public static DialogResult Show(string text, string caption, MessageBoxButtons buttons);

例子:MessageBox.Show("内容","标题",要在消息框中显示的按钮);

   MessageBox.Show("内容", "标题", MessageBoxButtons.OK);

4.

//

// 摘要:

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

//

// 参数:

// text:

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

//

// caption:

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

//

// buttons:

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

//

// icon:

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

//

// 返回结果:

// System.Windows.Forms.DialogResult 值之一。

//

// 异常:

// System.ComponentModel.InvalidEnumArgumentException:

// 指定的 buttons 参数不是 System.Windows.Forms.MessageBoxButtons 的成员。- 或 - 指定的 icon

// 参数不是 System.Windows.Forms.MessageBoxIcon 的成员。

//

// System.InvalidOperationException:

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

// 属性指定的。

public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);

 

例子:MessageBox.Show("内容","标题",MessageBox.Button,按钮,MessageBox.Icon.图标);

       MessageBox.Show("内容", "标题", MessageBoxButtons.OK,MessageBoxIcon.Warning);  

 

5.

// 摘要:

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

//

// 参数:

// text:

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

//

// caption:

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

//

// buttons:

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

//

// icon:

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

//

// defaultButton:

//

// 返回结果:

// 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

// 属性指定的。

public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);

//MessageBox.Show("内容", "标题", 要显示的按钮,要显示的图标,设置默认按钮);

//设置第一个按钮为默认按钮,代码如下:

 

 MessageBox.Show("内容", "标题", MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);

6.

//

// 摘要:

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

//

// 参数:

// 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。- 或 - buttons

// 指定了无效的 System.Windows.Forms.MessageBoxButtons 组合。

public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options);

 

7.

//

// 摘要:

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

//

// 参数:

// text:

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

//

// caption:

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

//

// buttons:

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

//

// icon:

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

//

// defaultButton:

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

//

// options:

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

// 0。

//

// helpFilePath:

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

//

// navigator:

// System.Windows.Forms.HelpNavigator 值之一。

//

// param:

// 用户单击"帮助"按钮时显示的帮助主题的数值 ID。

//

// 返回结果:

// 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 组合。

public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param);

 

转载地址:http://twinl.baihongyu.com/

你可能感兴趣的文章
对于sqli-labs基础篇全程使用sqlmap不用手工注入(七夕礼物!!!)
查看>>
C++雾中风景11:厘清C++类型转换(static_cast,dynamic_cast,reinterpret_cast,const_cast)
查看>>
为什么开发人员必须要了解数据库锁?
查看>>
Lua 学习笔记(二)—— 语句
查看>>
制作自己的Vagrant Box
查看>>
NetCore实践篇:分布式监控客户端ZipkinTracer从入门到放弃之路
查看>>
JAVA学习摘要
查看>>
[Java开发之路](23)装箱与拆箱
查看>>
TextView实现跑马灯效果
查看>>
Mysql字段名与保留字冲突导致的异常解决
查看>>
Rust 1.33.0 发布,OSC 上堪称“零差评”的编程语言
查看>>
Android MotionEvent详解
查看>>
单例模式
查看>>
现在到底还该不该买房?
查看>>
小程序中文件相关api总结
查看>>
Go 标准库 http.FileServer 实现静态文件服务
查看>>
第十四章:绝对布局(三)
查看>>
Fluwx:让在Flutter中使用微信SDK成为可能
查看>>
《Groovy极简教程》第3章 Groovy基本语法
查看>>
百度贴吧 | 通用抓图脚本
查看>>