日期:2014-05-17  浏览次数:21154 次

radiobutton点击赋值问题
intAnswer[intID - 1] = Convert.ToInt32(((RadioButton)sender).Tag);
strAnswer[intID - 1] = ((RadioButton)sender).Text.Trim();

这两句运行会提示:
无法将类型为“System.Windows.Forms.Panel”的对象强制转换为类型“System.Windows.Forms.RadioButton”。


但并不是每次都提示,这是什么原因啊?
C#

------解决方案--------------------
别用sender直接使用控件名称
如果你要用sender你要确保你的这个事件是randiobutton传过来的
------解决方案--------------------
事件触发没点到RadioButton 点到他的容器Panel了