C#Windows的HelloWorld

在MSDN中找到Form类:MSDN-->.NET开发-->.NET Framework SDK 2.0-->Class Library Reference -->System.Windows.Forms 命名空间

http://msdn.microsoft.com/zh-cn/library/system.windows.forms%28v=vs.80%29.aspx

阅读文档,解决以下问题:

1.

 

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

 

转载于:https://www.cnblogs.com/feng-fan/p/3320944.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值