winform中messageBox七个参数的使用(转载)
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(" 1 个参数 ”);
}

private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(" 2 个参数。。 ",
"亮仔提示"
);
}

private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show(" 3 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.YesNoCancel
);
}

private void button4_Click(object sender, EventArgs e)
{
MessageBox.Show(" 4 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning
);
}

private void button5_Click(object sender, EventArgs e)
{
MessageBox.Show(" 5 个参数。。 。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2
);
}

private void button6_Click(object sender, EventArgs e)
{
MessageBox.Show(" 6 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RtlReading //ServiceNotification//.RightAlign // 标题向右对齐。
);
}

private void button7_Click(object sender, EventArgs e)
{
MessageBox.Show(" 7 个参数。。帮助菜单不可用。。。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RightAlign,
true // 标题向右对齐。。。。。 );
}

private void button8_Click(object sender, EventArgs e)
{
MessageBox.Show(" 7 个参数。帮助菜单 可用。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RightAlign , // 要使用默认风格,此处参数可设为 0
@"C:\Documents and Settings\Administrator\桌面\新建文本文档.txt"
);
}

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 组合。
下面对C#中的预编译指令进行介绍:
1.#define和#undef
用法:
#define DEBUG
#undef DEBUG
#define告诉编译器,我定义了一个DEBUG的一个符号,他类似一个变量,但是它没有具体的值,可以将它看为一个符号而已。#undef就是删除这个符号的定义。如果符号DEBUG没定义过,则#undef不起作用,否则#define不起作用。二者都必须放在源代码之前。二者的顺序看代码的顺序:
#define DEBUG
#undef DEBUG
这样的话,DEBUG是没有定义的,如果二者换个顺序,编译器就认为DEBUG被定义了
2.#if、#elif、#else、#endif
这个告诉编译器进行编译代码的流程控制。考虑下面代码:
#if DEBUG
Console.Write("debug");
#elif RELEASE
Console.Write("release");
#else
Console.Write("other");
#endif
以上代码就是说如果定义了DEBUG则输出debug,定义了RELEASE,则输出realse,否则输出other。如果定义了DEBUG和REALSE会怎么样呢?各位可以自己试一下。
3.#warning、#error
通过这两个指定可以告诉编译器,出一个警告还是错误信息。除了错误信息以后,编译将停止。
参考下面的代码(C#在Debug状态下自动定义DEBUG标志,但Release状态不会自动定义RELEASE标志):
#if DEBUG
#warning 现在是Debug状态
#elif RELEASE
#warning 现在是Release状态
#else
#error 并清楚什么状态
#endif
4.#region 和#endregion
这个两个用来组成代码块
5.#line
这个指令可以改变编译器在警告和错误信息中显示的文件名和行号信息,用#line default把行号恢复为默认的行号。
#line [ number ["file_name"] | default ]
number
要为源代码文件中后面的行指定的编号。
"file_name"(可选)
希望出现在编译器输出中的文件名。默认情况下,使用源代码文件的实际名称。文件名必须括在双引号 ("") 中。
default
重置文件中的行编号。
备注
#line 可能由生成过程中的自动中间步骤使用。例如,如果中间步骤从原始的源代码文件中移除行,但是您仍希望编译器基于文件中的原始行号生成输出,则可以移除行,然后用 #line 模拟原始行号。
下面的示例说明如何报告与行号关联的两个警告。#line 200 指令迫使行号为 200(尽管默认值为 #7)。另一行 (#9) 作为默认 #line 指令 的结果跟在通常序列后。
示例1:
// preprocessor_line.cs
public class MyClass2
{
public static void Main()
{
#line 200
int i; // line 200
#line default
char c; // line 9
}
}
示例2:
下面的示例说明调试器如何忽略代码中的隐藏行。运行此示例时,它将显示三行文本。但是,当设置如示例所示的断点并按 F10 键逐句通过代码时,您将看到调试器忽略了隐藏行。另请注意,即使在隐藏行上设置断点,调试器仍会忽略它。
// preprocessor_linehidden.cs
using System;
class MyClass
{
public static void Main()
{
Console.WriteLine("Normal line #1."); // Set a break point here.
#line hidden
Console.WriteLine("Hidden line.");
#line default
Console.WriteLine("Normal line #2.");
}
}
6.#pragma
可以抑制或恢复指定的编译警告。与命令行选项不同,#pragma指令可以在类和方法上执行,对抑制什么警告和抑制的时间进行更精细的控制。
#pragma warning disable 169
public class Aclass
{
int nFiled;
}
#pragma warning restore 169
winform中messageBox七个参数的使用(转载)的更多相关文章
- C# WinForm 中 MessageBox的使用详解
1.C# WinForm 中 MessageBox的使用详解:http://www.cnblogs.com/bq-blog/archive/2012/07/27/2611810.html
- C# winform 中MessageBox用法大全(附效果图) (转载+说明)
声明:这篇文章是转载的转载的,由于原作者的博客被关闭 我就不再列出了,提前先说明下,if语句中的判断有些太长,建议提前声明一个变量, DialogResult MsgBoxResult; ...
- C#中Messagebox.Show()常用参数用法详解
声明:IWin32Window owner , HelpNavigator navigator , string keyword 上面的三个参数类型不是很了解.没有做讨论. 等以后了解多了 ...
- WinForm中AssemblyInfo.cs文件参数具体讲解
在.NET中有一个配置文件AssemblyInfo.cs主要用来设定生成的有关程序集的常规信息dll文件的一些参数,下面是默认的AssemblyInfo.cs文件的内容具体介绍 //是否符合公共语言规 ...
- C# winform 中MessageBox用法大全(附效果图)
我们在程序中经常会用到MessageBox. MessageBox.Show()共有21中重载方法.现将其常见用法总结如下: 1.MessageBox.Show(“Hello~~~~”); 最简单的, ...
- winform 中 MessageBox 用法大全
(转自:http://blog.csdn.net/xuenzhen123/article/details/4808005) MessageBox.Show()共有21中重载方法.现将其常见用法总结如下 ...
- WinForm中使MessageBox实现可以自动关闭功能
WinForm 下我们可以调用MessageBox.Show 来显示一个消息对话框,提示用户确认等操作.在有些应用中我们需要通过程序来自动关闭这个消息对话框而不是由用户点击确认按钮来关闭.然而.Net ...
- 如何在WinForm中发送HTTP请求
如何在WinForm中请求发送HTTP 手工发送HTTP请求主要是调用 System.Net的HttpWebResponse方法 手工发送HTTP的GET请 求: string strURL = &q ...
- 关于FastReport在winform中的使用(包含FastReport.net的安装步骤链接)
一.FastReport的简介 FastReport是功能齐全的报表控件,使开发者可以快速并高效地为·NET/VCL/COM/ActiveX应用程序添加报表支持. 二.FastReport的安装(推荐 ...
随机推荐
- 基于HTML5的网络拓扑图
电信网管系统中,设备状态信息的实时展示非常重要,通常会挂载一堆图标来展示状态或告警信息,图标的信息量有限,有时需要更详细的面板,甚至以图表的形式展现,本文将结合最近客户提到的需求,使用 Qunee1. ...
- 预装win8的系统换win7需要做的bios设置
https://zhidao.baidu.com/question/873669708066476212.html (一)联想G50-70由于预装的是WIN8位系统,哪么改装WIN7 64位的方法如下 ...
- ios 大图 真机不显示的问题
png的图片只是命名为png,格式不是png的. 打开terminal终端,cd图片目录,输入命令sips -s format png *.* --out pngs,再把图片覆盖即可
- 在CSS中通过@font-face属性来实现网页中嵌入特殊字体。
首先获取要使用字体的三种文件格式.EOT..TTF或.OTF..SVG,确保能在主流浏览器中都能正常显示该字体..EOT,适用于Internet Explorer 4.0+.TTF或.OTF,适用于F ...
- UVA 820 --- POJ 1273 最大流
找了好久这两个的区别...UVA820 WA了 好多次.不过以后就做模板了,可以求任意两点之间的最大流. UVA 是无向图,因此可能有重边,POJ 1273是有向图,而且是单源点求最大流,因此改模板的 ...
- 内网公告牌获取天气信息解决方案(C# WebForm)
需求:内网公告牌能够正确显示未来三天的天气信息 本文关键字:C#/WebForm/Web定时任务/Ajax跨域 规划: 1.天定时读取百度接口获取天气信息并存储至Txt文档: 2.示牌开启时请求Web ...
- js完美身份证验证
/*根据[中华人民共和国国家标准 GB 11643-1999]中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成.排列顺序从左至右依次为:六位数字地址码,八位数 ...
- Mysql修改日期,时间不变的做法
UPDATE tra_bargainorder SET EndParkingTime = ADDTIME (CURDATE() + INTERVAL 0 HOUR,TIME(EndParkingTim ...
- mySql中IFNULL的使用说明
IFNULL(expr1,expr2) 如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值 具体用法如:现有学生表(tbl_stu ...
- (转) Spring框架笔记(二十五)——NamedParameterJdbcTemplate与具名参数(转)
在经典的 JDBC 用法中, SQL 参数是用占位符 ? 表示,并且受到位置的限制. 定位参数的问题在于, 一旦参数的顺序发生变化, 就必须改变参数绑定. 在 Spring JDBC 框架中, 绑定 ...