C#按钮判断问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 04:08:09
在button3中编写代码,如果button1被点击,则输出1;如果button2被点击,则输出2。编译器是visual studio2005。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication14
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public int butt=0;
private void Form2_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
butt = 1;
}

private void button2_Click(object sender, EventArgs e)
{
butt = 2;
}

private void button3_Click(object sender, EventArgs e)
{
if(butt==1)
{
MessageBox.Show("1");