带有按钮并且可以执行单击事件的WINFORM窗体,体悟C#的创建过程

来源:互联网 发布:nginx 外网访问内网 编辑:程序博客网 时间:2024/06/03 11:17
using System;using System.Drawing;using System.Windows.Forms;namespace Window{class Window{static void Main(){Application.Run(new Init());}}class Init:Form{public Init(){Text = "继承自Form的窗体";BackColor = Color.White;Button btn = new Button();btn.Width = 150;btn.Text = "你好";btn.Location = new Point(80,50);btn.Click += new EventHandler(this.btn_Click);Controls.Add(btn);}private void btn_Click(object sender,EventArgs e){MessageBox.Show("我是按钮事件点击出来的弹窗","我是弹窗的标题");}}}
都是为了最简化的去执行一个程序,让初学者能一步到位的了解为什么这么写和为什么要这么写
1 0
原创粉丝点击