Click here to Skip to main content
15,868,102 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 27-Sep-17 1:26am
Comments
Karthik Harve 23-Jul-12 8:14am    
What have you tried? Where are you facing the problem.
[no name] 23-Jul-12 8:14am    
I don't know hw to write the coding...
[no name] 23-Jul-12 8:22am    
I Don't want to add or subtraction just i need to check radio button 1 and when i'm checking it radio button 2 should get invisible.
Karthik Harve 23-Jul-12 8:26am    
that example will show you how to use the Radio buttons. So, understand and code it according to your need.
JakirBB 23-Jul-12 8:15am    
Is it for web/desktop app?

C#
if(radiobutton1.checked)
{
  radiobutton2.Visible =false;

}
else if(radiobutton2.checked)
{
  radiobutton1.Visible =false;
}
 
Share this answer
 
v2
Comments
Member 10404120 16-Nov-13 10:23am    
Thanks.
If i want to hide what i was selected radiobutton.
Member 10404120 16-Nov-13 10:24am    
Thanks.
But If i want to hide what i selected button.
How to do it ?
Hi,

check this[^] for how to use radio buttons.
 
Share this answer
 
Quote:
I have 2 radio buttons as Male and Female. My requirement is when i select Male(Radiobutton1) the other Female(Radiobutton2) must hide

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:

HTML
GroupName="Sex"


--Amit
 
Share this answer
 
C#
private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
                radioButton2.Hide();
        }
 
Share this answer
 
hi sometime it's not work and i have this solution for it :
it's different code but i want to see concept of coding

C#
string pricemode = dt.Rows[0]["pricemode"].ToString();
  if (pricemode == "1")
  {

 RadioButton_countMode.Checked = true;
 RadioButton_unitcountMode.Checked = false;
   }
else
{
RadioButton_unitcountMode.Checked = true;
RadioButton_countMode.Checked = false;
}
 
Share this answer
 
Comments
CHill60 3-Jul-16 17:25pm    
Is this meant to be a solution or a question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900