日期:2014-05-20  浏览次数:21089 次

c#中如何使用groupBox让单选按钮分组?
我把三个单选按钮放入一个groupBox中,如和点击不同的单选按钮产生不同的事件?

但是我这样写,运行后最后一个点击的单选按钮产生不了事件

private   void   radioButton1_CheckedChanged_1(object   sender,   System.EventArgs   e)
{
if(this.radioButton1.Checked)
MessageBox.Show( "1 ");
else   if(this.radioButton2.Checked)
MessageBox.Show( "2 ");
else   if(this.radioButton3.Checked)
MessageBox.Show( "3 ");

}
请问各位如何解决?

------解决方案--------------------
在代码中找到像如下的代码:
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);

this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);

this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);

分别删除,
然后在分别各个添加事件就行了