本文整理汇总了C#中System.Windows.Forms.Application类的典型用法代码示例。如果您正苦于以下问题:C# Application类的具体用法?C# Application怎么用?C# Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于System.Windows.Forms命名空间,在下文中一共展示了Application类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public class Form1 : Form
{
[STAThread]
public static void Main()
{
// Start the application.
Application.Run(new Form1());
}
private Button button1;
private ListBox listBox1;
public Form1()
{
button1 = new Button();
button1.Left = 200;
button1.Text = "Exit";
button1.Click += new EventHandler(button1_Click);
listBox1 = new ListBox();
this.Controls.Add(button1);
this.Controls.Add(listBox1);
}
private void button1_Click(object sender, System.EventArgs e)
{
int count = 1;
// Check to see whether the user wants to exit the application.
// If not, add a number to the list box.
while (MessageBox.Show("Exit application?", "",
MessageBoxButtons.YesNo)==DialogResult.No)
{
listBox1.Items.Add(count);
count += 1;
}
// The user wants to exit the application.
// Close everything down.
Application.Exit();
}
}