问题描述
我有2个单选按钮,分别为男性和女性。我的要求是当我选择男性(Radiobutton1)时其他女性(Radiobutton2)必须隐藏
请帮助,如何做到这一点。
谢谢
Balamurugan
I have 2 radio buttons as Male and Female. My requirement is when i select Male(Radiobutton1) the other Female(Radiobutton2) must hide
Please help , how to do this.
Thanks
Balamurugan
推荐答案
if(radiobutton1.checked)
{
radiobutton2.Visible =false;
}
else if(radiobutton2.checked)
{
radiobutton1.Visible =false;
}
我有2个单选按钮,如男性和女性。我的要求是当我选择男性(Radiobutton1)时,另一个女性(Radiobutton2)必须隐藏
I have 2 radio buttons as Male and Female. My requirement is when i select Male(Radiobutton1) the other Female(Radiobutton2) must hide
隐藏按钮不是最好的做法总是。而不是你可以为单选按钮设置 GroupName
,一次只能选择一个。
在两个单选按钮中添加以下内容:
Hi,
Hiding the buttons will not be the best practice always. Instead of that you can set the GroupName
for both the radio button as same to select only one at a time.
In both radio button add this:
GroupName="Sex"
--Amit
--Amit
这篇关于C#中的单选按钮编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!