日期:2014-06-10  浏览次数:20636 次

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);