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("我是按钮事件点击出来的弹窗","我是弹窗的标题"); } } }都是为了最简化的去执行一个程序,让初学者能一步到位的了解为什么这么写和为什么要这么写
带有按钮并且可以执行单击事件的WINFORM窗体,体悟C#的创建过程
最新推荐文章于 2025-05-15 10:30:31 发布