我的问题是,我必须写什么代码才能使radiobutton1
显示checkboxlist1
不可见 - >Visible
设置为False
。Radiobutton必须勾选以显示复选框
只有当radiobutton1
被选中时,我才想显示checkboxlist
。
我正在使用visual c#2012。希望你能帮助。
我的问题是,我必须写什么代码才能使radiobutton1
显示checkboxlist1
不可见 - >Visible
设置为False
。Radiobutton必须勾选以显示复选框
只有当radiobutton1
被选中时,我才想显示checkboxlist
。
我正在使用visual c#2012。希望你能帮助。
您使用Checked
RadioButton
的属性来标识是否检查了RadioButton。
从MSDN:RadioButton.Checked
获取或设置指示该控制是否被选中的值。
试试这个:
if(radioButton1.Checked)
{
//Enable checkboxlist
CheckBoxList1.Visible=true;
}
编辑: 你应该处理它的RadioButton
的CheckedChanged事件处理程序试试这个:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if(radioButton1.Checked)
{
//Enable checkboxlist
CheckBoxList1.Visible=true;
}
}
编辑: 如果要禁止其他单选按钮试试这个:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if(radioButton1.Checked)
{
//Enable checkboxlist
CheckBoxList1.Visible=true;
//Disable RadioButton
RadioButton2.Visible=false;
}
}
你可以做
CheckBoxList1.Visible = radioButton1.Checked
好吧,我不喜欢你告诉我,但现在当我检查的形式单选按钮,在CheckBoxList的不出现。在那里应该是空白区域... – user3083561
@ user3083561:你应该在RadioButton检查事件处理程序中处理它。检查我编辑的答案。 –
我可以再问一件吗? 当我选择一个单选按钮和checkboxlist显示我想禁用其他单选按钮。那可能吗 ? – user3083561