Winform 在一个事件中调用其他按钮(button1)的点击事件

代码如下:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("test");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 调用 button1.Click()
            button1.PerformClick();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            // 调用 button1.Click()
            button1_Click(null, null);
        }
    }


热门推荐