MessageBox.Show();可谓是winform开发中用的次数最多的东东啦。先贴一张msdn的图解

msdn好像没有更新哎,只提供了这几种方法,并且参数名称和最新的有差别,但实际上messagebox.show()有21种重载方法,用的时候再细细查看吧。基本上都有返回结果,返回结果的如下表,一般在if判断中使用,比如DialogResult.OK这样的。

下面简单举几个例子。

 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 的成员。- 或 - 指定的 icon
// 参数不是 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。- 或 - buttons
// 指定了无效的 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 值之一。
//
// 异常:
// 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 组合。
 也是  个参数
. (也是 个参数)
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 组合。

winform之2---messagebox用法的更多相关文章

  1. C# MessageBox 用法大全(转)

    C# MessageBox 用法大全 http://www.cnblogs.com/Tammie/archive/2011/08/05/2128623.html 我们在程序中经常会用到MessageB ...

  2. paip.c++ qt messagebox用法

    paip.c++ qt messagebox用法 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net ...

  3. C#中MessageBox用法大全(转)

    我们在程序中经常会用到MessageBox. MessageBox.Show()共有21中重载方法.现将其常见用法总结如下: 1.MessageBox.Show("Hello~~~~&quo ...

  4. C# winform 中MessageBox用法大全(附效果图) (转载+说明)

    声明:这篇文章是转载的转载的,由于原作者的博客被关闭 我就不再列出了,提前先说明下,if语句中的判断有些太长,建议提前声明一个变量, DialogResult MsgBoxResult;        ...

  5. C# winform 中MessageBox用法大全(附效果图)

    我们在程序中经常会用到MessageBox. MessageBox.Show()共有21中重载方法.现将其常见用法总结如下: 1.MessageBox.Show(“Hello~~~~”); 最简单的, ...

  6. winform 中 MessageBox 用法大全

    (转自:http://blog.csdn.net/xuenzhen123/article/details/4808005) MessageBox.Show()共有21中重载方法.现将其常见用法总结如下 ...

  7. winform TreeView的一些用法以及异步加载

    今天,主要弄了一下对于树型控件的一些方法,以及异步加载.参考: http://www.cnblogs.com/greatverve/archive/2012/03/23/winform-treevie ...

  8. C#中MessageBox用法大全

    我们在程序中经常会用到MessageBox. MessageBox.Show()共有21中重载方法.现将其常见用法总结如下: 1.MessageBox.Show("Hello~~~~&quo ...

  9. c# MessageBox 用法大全

    我们在程序中经常会用到MessageBox. 1.MessageBox.Show("Hello~~~~"); 最简单的,只显示提示信息. 2.MessageBox.Show(&qu ...

  10. MFC之MessageBox用法

    一    函数原型及参数 function MessageBox(hWnd: HWND; Text, Caption: PChar; Type: Word): Integer; hWnd:对话框父窗口 ...

随机推荐

  1. UC/0S2之基础总结

    堆栈,就是在存储器中按数据“后进先出(LIFO)[类比杯子]”的原则组织的连续存储空间,为了满足任务切换和响应中断保存CPU寄存器中的内容及存储任务私有数据的需要,每个任务都应该配有自己的堆栈, 注意 ...

  2. Android学习之DragEvent

    关于DragEvent Google Android API中是这么说的 Represents an event that is sent out by the system at various t ...

  3. Oracle存储包存储及案例

    Package左侧文件: create or replace package S02_ZFRZPT_YS_MID is procedure start_cal(strgranularity in va ...

  4. Java排序之排序大综合

    一.最近写了一些排序,于是和和大家分享一下:(默认都是从小到大排序) 二.冒泡排序 1.什么是冒泡排序:原理是临近的两个数比较大小,将较大的数往后移,这样遍历一趟数组以后,最大的数就排在的最后面(时间 ...

  5. C#后台跳转

    后台跳转的方法: 1.js脚本 [不推荐使用] Context.Response.Write("<script language=javascript>window.locati ...

  6. PHP学习笔记13-操作Cookie

    PHP会话管理图: 创建index.php: <?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/7/1 * ...

  7. C语言新学备忘_1

    #include <stdio.h> //C语言的标准输入 ,输出头文件扩展名为.h的文件称为头文件 //include称为文件包含命令 #include <stdlib.h> ...

  8. 转: seajs手册与文档之 -- require规则

    require 规则 正确拼写 不要修改 使用直接量 动态依赖的小提示 书写规则 使用 SeaJS 书写模块代码时,需要遵循一些简单规则: 1. 正确拼写 在模块代码中,第一个参数 必须 命名为 re ...

  9. DDB与DIB的区别

    DDB(设备相关位图) DDB依赖于具体设备:DDB的颜色模式必需与输出设备相一致.例如,如果当前的显示设备是256色模式,那么DDB必然也是256色的.在256色以下的位图中存储的像素值是系统调色板 ...

  10. 针对苹果最新审核要求 为应用兼容IPv6

    本文授权转载,作者:我不是段誉(简书) 在WWDC2 015上苹果宣布iOS 9将支持纯IPv6的网络服务.2016年初开始所有提交到App Store的应用必须支持IPv6.而今年5月初,苹果宣布6 ...