Form1.cs
using System;
……
namespace self_1_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Button button1 = new Button();
button1.Click += new System.EventHandler(this.button1_Click);
button1.Text = "加油";
this.Controls.Add(button1);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("自学第一天,很努力很努力,很开心很开心");
}
}
}
Program.cs
using System;
……
namespace self_1_1
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}