调用button的click事件时。this.button1.perpform()与this.button1_click(this,null)有何不同?

解决方案 »

  1.   

    EventArgs 一个实力了 一个为NULL
      

  2.   

    this.button3.PerformClick();           
     
    this.button3_Click(this, null);我是指这两个方法有何不同!!!
      

  3.   

    你有没有亲自试过这两个方法??如果真是一样的我还来这里问什么?
    别不服气,给你段代码,自己回去好好试试.看看是不是一样的!
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            int i = 0;
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("点击了Button而显示消息");        }        private void Form1_Resize(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Visible = false;
                    this.notifyIcon1.Visible = true;
                }
            }        private void notifyIcon1_Click(object sender, EventArgs e)
            {
                this.notifyIcon1.Visible = false;
                this.Visible = true;
                this.WindowState = FormWindowState.Normal;
                this.timer1.Stop();
                this.timer2.Stop();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                this.button1_Click(this, null);
                timer1.Stop();
            }        private void timer2_Tick(object sender, EventArgs e)
            {
                this.button1.PerformClick();
            }        private void button2_Click(object sender, EventArgs e)
            {
                this.WindowState = FormWindowState.Minimized;
                this.timer1.Start();
            }        private void button3_Click(object sender, EventArgs e)
            {
                this.WindowState = FormWindowState.Minimized;
                this.timer2.Start();
            }
        }
    }
      

  4.   

    this.button3_Click(this, null); 
    直接调用.this.button3.PerformClick();          
    通过产生button3的Click事件来调用.
    如果执行了this.button3.Click-=new EventHandler(button3_Click);  //取消button3的click事件.
    后.
    执行this.button3.PerformClick();   则不会执行this.button3_Click(...);
      

  5.   

    也就是是说button_Click()方法,直接执行的是方法内的代码.
    而button_performClick()是调用的Event事件.可以这么理解吧?
      

  6.   

    想跳用click()里面执行的代码啊,这两种写法都是很春的。