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

namespace WinFormsApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e) //Sender就是这么用的,它是消息的发送者/拥有者
        {
            if (sender == this.button1)
            {
                textBox1.Text = "按钮1被点击";
            }
            if (sender == this.button2)

            {
                this.textBox1.Text = "按钮2被点击";
            }
        }
    }
}

最后修改:2022 年 12 月 05 日
如果觉得我的文章对你有用,请随意赞赏