首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

radioButton1.Checked==true 疏失

2012-08-22 
radioButton1.Checkedtrue 出错?C# VS2005运行 radioButton1.Checkedtrue时报错:只有 assignment、call

radioButton1.Checked==true 出错?
C# VS2005
运行 radioButton1.Checked==true
时报错:只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
而 bool test=radioButton1.Checked 又能正常执行。

[解决办法]
在判断语句中吗?
为什么是两个等号?
如果是在判断语句中,不要后面的试试:
if(radioButton1.Checked)
{

}
[解决办法]
赋值语句有问题

1. button.checked = true;

2. if(button.checked == true)
{
}
[解决办法]
要赋值的话,radionButton1.Checked=true;
要判断当前值:if(radioButton1.Checked)
[解决办法]
RadioButton的Checked属性

C# code
        //        // 摘要:        //     获取或设置一个值,该值指示是否已选中控件。         //        // 返回结果:        //     若选中了复选框,则为 true;反之,则为 false
[解决办法]
顶一下
[解决办法]
判断语句用 ==

你想赋值的话,用 =

把你的语句改成

radioButton1.Checked=true 



if(radioButton1.Checked==true ){}

就没错

建议看下编程的基础书籍。
[解决办法]
radioButton1.Checked=true
[解决办法]
只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
很明显 radioButton1.Checked==true; 不能作为单一语句

热点排行