关于CheckBox的CheckedChanged事件,在窗体LOAD时他也会触发此事件,我要怎样才能在load方法时不触发此事件,急!

解决方案 »

  1.   

    一、在Form_Load里添加数据前先注销事件,处理完再注册事件;
    二、在类里定义一个标志变量,事件里检查,跳过第一次调用。第一种方法最好!checkBox1.ItemCheck -= new EventHandler(checkBox1_ItemCheck);//Add
    ........
    checkBox1.ItemCheck += new EventHandler(checkBox1_ItemCheck);//Add
      

  2.   

    不会的,一定是你的form_load 或 构造里面改了它的值。
      

  3.   

    1、请问下还有别的方法吗,
    一、在Form_Load里添加数据前先注销事件,处理完再注册事件;
    二、在类里定义一个标志变量,事件里检查,跳过第一次调用。第一种方法最好!checkBox1.ItemCheck -= new EventHandler(checkBox1_ItemCheck);//Add
    ........
    checkBox1.ItemCheck += new EventHandler(checkBox1_ItemCheck);//Add  
      

  4.   

    不是很明白,是不是在load 方法的最后加上
    checkBox1.ItemCheck += new EventHandler(checkBox1_ItemCheck);//Add
      

  5.   

    是的,我是在LOAD的时给他付值了,但我想LOAD的时候不触发此事件
      

  6.   

    void form1_Load(...)
    {
    checkBox1.ItemCheck -= new EventHandler(checkBox1_ItemCheck);//Add........//添加值、赋值等操作checkBox1.ItemCheck += new EventHandler(checkBox1_ItemCheck);//Add
    }
      

  7.   


    checkBox1.ItemCheck += new EventHandler(checkBox1_ItemCheck);
    加到form1_Load(...)里,去掉构造函数中的那个。