选择另一个复选框时,勾出一个复选框 [英] greaying out a check box whenother one get selected

查看:101
本文介绍了选择另一个复选框时,勾出一个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码下面的样子,将禁用一个复选框,以使得用户won''t能够检查它正在检查它旁边的其它复选框时.例如,如果正在检查是"按钮,则我希望否"按钮被禁用或变灰.但是我不知道如何使用以下代码来做到这一点.有人可以帮我吗.

for(int i = 0; i< CheckBoxList1.Items.Count; i ++)
{
如果(CheckBoxList1.Items [i] .Selected)
CheckBoxList2.Items [i] .Enabled = false;
其他
CheckBoxList2.Items [i] .Enabled = true;
}

我应该把它放在页面加载或button_click方法中还是其他地方?还是需要做更多事情?

this code below looks like it would disable a check box so that a user won''t be able to check it when the other check box beside it is being checked. for example if yes button is being checked i want the no button is to be disabled or ie greyed out. but i don''t know how to do that with the following code. can some one help me please.

for (int i = 0; i< CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
CheckBoxList2.Items[i].Enabled = false;
else
CheckBoxList2.Items[i].Enabled = true;
}

should I put it in page load or button_click method or where else? or there is something more I have to do?

推荐答案

为什么要禁用no复选框?如果禁用它,应该如何检查?

您不想使用单选按钮吗?

我认为您非常需要坐下来重新考虑您的设计.您已经在这里待了三天了,并且仍然很喜欢复选框.
Why would you want the no checkbox to be disabled? How are you expected to check it if it''s disabled?

Wouldn''t you rather use radio buttons?

I think you SERIOUSLY need to sit down and rethink your design. You''ve been at this for three days now,and you''re still dickin'' around with checkboxes.


这篇关于选择另一个复选框时,勾出一个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆