日期:2014-05-18  浏览次数:21232 次

radiobutton的CheckedChanged事件与Click事件
C# code

private void radioButton1_CheckedChanged(object sender, EventArgs e) 
{ 
    if (radioButton1.Checked) 
            { 
                clsGridStyle.rdo1(); 
                clsCellCompute.rdo1(); 
                clsStatistics.rdo1(); 
                ListGrid.OwnerDrawCell += new FlexCell.Grid.OwnerDrawCellEventHandler(clsDrawImage.rdo1); 
                ListGrid.MouseDown += new FlexCell.Grid.MouseDownEventHandler(clsMouseDown.rdo1); 
                ListGrid.MouseDoubleClick += new MouseEventHandler(clsMouseDoubleClick.rdo1);                
            } 
            else 
            { 
                ListGrid.OwnerDrawCell -= new FlexCell.Grid.OwnerDrawCellEventHandler(clsDrawImage.rdo1); 
                ListGrid.MouseDown -= new FlexCell.Grid.MouseDownEventHandler(clsMouseDown.rdo1); 
                ListGrid.MouseDoubleClick -= new MouseEventHandler(clsMouseDoubleClick.rdo1); 
            } 
} 




rdo1,rdo2,rdo3,rdo4.....最初都是用的CheckedChanged事件

现改为用Click事件

C# code

private void radioButton1_Click(object sender, EventArgs e) 
{ 
    if (radioButton1.Checked) 
            { 
                clsGridStyle.rdo1(); 
                clsCellCompute.rdo1(); 
                clsStatistics.rdo1(); 
                ListGrid.OwnerDrawCell += new FlexCell.Grid.OwnerDrawCellEventHandler(clsDrawImage.rdo1); 
                ListGrid.MouseDown += new FlexCell.Grid.MouseDownEventHandler(clsMouseDown.rdo1); 
                ListGrid.MouseDoubleClick += new MouseEventHandler(clsMouseDoubleClick.rdo1);                
            } 
            else 
            { 
                ListGrid.OwnerDrawCell -= new FlexCell.Grid.OwnerDrawCellEventHandler(clsDrawImage.rdo1); 
                ListGrid.MouseDown -= new FlexCell.Grid.MouseDownEventHandler(clsMouseDown.rdo1); 
                ListGrid.MouseDoubleClick -= new MouseEventHandler(clsMouseDoubleClick.rdo1); 
            } 
} 




但是在rdo1、rdo2、rdo3....切换时,发现

C# code
ListGrid.OwnerDrawCell -= new FlexCell.Grid.OwnerDrawCellEventHandler(clsDrawImage.rdo1); 
ListGrid.MouseDown -= new FlexCell.Grid.MouseDownEventHandler(clsMouseDown.rdo1); 
ListGrid.MouseDoubleClick -= new MouseEventHandler(clsMouseDoubleClick.rdo1); 



没有执行,绘制的图片线条,发生了叠加

CheckedChanged事件 与 Click 事件有什么不同吗?如何解决呢?

------解决方案--------------------
这是单选框,你点击它选中后,再次点击不会发生 Checked的变换