如果再程序里给CellvalueChanged多次绑定了this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
            this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);有没有什么方法能够得到CellValueChanged绑定事件的次数

解决方案 »

  1.   

    用一个变量记录一下就行了啊。
    定义一个变量 int i=0;
    this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
    i++;
                this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
    i++;
      

  2.   

    呵呵,可能我表达的不清楚,其实是因为程序比较混乱,导致有的地方重复绑定了changed事件,所以我想在绑定事件之前都判断一下是否已经绑定了change事件,如果已经绑定了,就不再绑定。
      

  3.   

    晕了,只能在类的内部才能获取到被注册的事件的次数,如果是我自己定义的事件,这个办法是可以实现的,但是Datagridview的cellvaluechanged是封装好的,这个方法没有办法获取到被注册的次数哦
      

  4.   

    找了帖子,用反射解决了,呵呵,晚上再结贴
    http://topic.csdn.net/u/20100311/16/7b4b38c8-ef42-41cb-aa75-b1546e54b849.html