新建一个窗体form2,其中有三个文本框,num1,num2,num3,在num1和num2中输入一个数字,求和的值在num3显示,建二个按纽,求和,取消,点取消文本框的内容清空?代码如下,但点取消按纽不起作用。
namespace wlj1024
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{ this.num3.Text = Convert.ToString(Convert.ToInt64(this.num1.Text) + Convert.ToInt64(this.num2.Text));
}
private void button2_Click(object sender, EventArgs e)
{
this.num1.Text="";
this.num2.Text = "";
this.num3.Text = "";
}
}
namespace wlj1024
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{ this.num3.Text = Convert.ToString(Convert.ToInt64(this.num1.Text) + Convert.ToInt64(this.num2.Text));
}
private void button2_Click(object sender, EventArgs e)
{
this.num1.Text="";
this.num2.Text = "";
this.num3.Text = "";
}
}
是否
button2.Click += new System.EventHandler(this.button2_Click);