C# MessageBox.Show
2012-07-06 10:09
309 查看
http://www.dotnetperls.com/messagebox-show
Dialog boxes interrupt users. They force users to respond before further action is taken. This is necessary in some situations. It is useful if a warning is important or an serious error occurred. TheMessageBox.Show method is the easiest way
to display a dialog box. It is available in C# Windows Forms programs.
The following example shows the MessageBox.Show method used in the Form1_Load event handler. To make the Form1_Load event handler, create a new Windows Forms application and double-click on the window in the designer.
In the F
Dialog boxes interrupt users. They force users to respond before further action is taken. This is necessary in some situations. It is useful if a warning is important or an serious error occurred. TheMessageBox.Show method is the easiest way
to display a dialog box. It is available in C# Windows Forms programs.
Examples
To start, the MessageBox.Show method is a static method, which means you do not need to create a new MessageBox() anywhere in your code. Instead, you can simply type "MessageBox" and press the period, and then select Show.The following example shows the MessageBox.Show method used in the Form1_Load event handler. To make the Form1_Load event handler, create a new Windows Forms application and double-click on the window in the designer.
Windows Forms program that uses MessageBox [C#] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication16 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // // The simplest overload of MessageBox.Show. [1] // MessageBox.Show("Dot Net Perls is awesome."); // // Dialog box with text and a title. [2] // MessageBox.Show("Dot Net Perls is awesome.", "Important Message"); // // Dialog box with two buttons: yes and no. [3] // DialogResult result1 = MessageBox.Show("Is Dot Net Perls awesome?", "Important Question", MessageBoxButtons.YesNo); // // Dialog box with question icon. [4] // DialogResult result2 = MessageBox.Show("Is Dot Net Perls awesome?", "Important Query", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); // // Dialog box with question icon and default button. [5] // DialogResult result3 = MessageBox.Show("Is Visual Basic awesome?", "The Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); // // Test the results of the previous three dialogs. [6] // if (result1 == DialogResult.Yes && result2 == DialogResult.Yes && result3 == DialogResult.No) { MessageBox.Show("You answered yes, yes and no."); } // // Dialog box that is right-aligned (not useful). [7] // MessageBox.Show("Dot Net Perls is the best.", "Critical Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign, true); // // Dialog box with exclamation icon. [8] // MessageBox.Show("Dot Net Perls is super.", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } }
In the F
相关文章推荐
- MessageBox.Show--C#
- C#中MessageBox.Show()方法详解
- C# MessageBox.Show
- C# Messagebox.show显示中文问题
- C# WinForm中实现MessageBox.Show()的常用方法
- c# messageBox.show()应用
- C# MessageBox.Show 用法
- c# MessageBox.Show 用法
- C#中MessageBox.Show的用法
- C#中的MessageBox的show的各种重载方法使用
- C#美化出现问题,MessageBox.Show 容量超出了最大容量。参数名: capacity
- C# MessageBox.Show 用法
- C#中MessageBox.Show问题(让提示窗口不显示在任务栏中)
- C#中Messagebox.Show()常用参数用法详解
- watin代码和神奇的MessageBox.Show语句(C#)
- C# MessageBox.Show 用法
- C# 弹框,提示错误:命名空间 'MessageBox' 中没有型别或命名空间名称‘Show’(您是否遗漏了组建参考?)
- c# messagebox .show()中如何换行
- C#中可以固定MessageBox.Show的方法
- C#中MessageBox.Show()实用方法