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. java--String常量池问题的几个例子

    关于string内存分配不错的博客:http://blog.csdn.net/rj042/article/details/6871030 String常量池问题的几个例子 示例1: Java代码 St ...

  2. 如何开始一个模块化可扩展的Web App(转)

    原文链接:http://avnpc.com/pages/start-a-modular-extensible-webapp 日志未经声明,均为AlloVince原创.版权采用『 知识共享署名-非商业性 ...

  3. gridview的高级使用

      后台数据 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...

  4. HTML之标签

    一.HTML 标签 HTML 标记标签通常被称为 HTML 标签 (HTML tag). •HTML 标签是由尖括号包围的关键词,比如 <html> •HTML 标签通常是成对出现的,比如 ...

  5. LeetCode 链表的插入排序

    Sort a linked list using insertion sort 创建一个新的链表,将旧链表的节点插入到正确的位置 package cn.edu.algorithm.huawei; pu ...

  6. ThinkPHP第八天(U函数放置在外部JS不会被解析,错误界面定制,错误信息变量)

    1.JS外部文件中U函数不会被解析,内部JS代码可以被解析. 2.halt. _404可以定制错误模板,在配置文件中配置 TMPL_EXCEPTION_FILE =>'./Public/Tpl/ ...

  7. Android 开发笔记 “线程交互(Handler+Thread 和 AsyncTask)”

    为什么需要线程 假设需要开发一个联网应用程序,需要从一个网址抓取网页内容,这里读取的网页地址是笔者在本地机器上自己建立的服务器地址.当然在读取网页内容的时候,可以使用HttpClient提供的API, ...

  8. bash:xxx:command not found

    前几天在centos6.0上配好了oracle 10g并且能够执行oracle相关命令,但是今天准备往oracle里倒数据时,执行sqlplus 出现bash:command not found [o ...

  9. Linux部署ASP.NET 5 (vNext)

    原文:Linux部署ASP.NET 5 (vNext) ASP.NET 5 (vNext) Linux部署   引言 工欲善其事,必先利其器. 首先,我们先明确下以下基本概念 Linux相关 Ubun ...

  10. java学习之动态代理模式

    package com.gh.dynaproxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Metho ...