Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am looking to show hide textbox and label together. I have 2 radio button one is Create and Manage, so if i select create radio, it should shows the textbox and label and when i select Manage, it should hide those controls.

I tried this way but not working. It is not hiding, only disable the user to write something on textbox.

VB
If RadioButton2.Checked = True Then
           ytcampname.Enabled = False
           Ytcamptextbox.Enabled = False
       End If

       If RadioButton1.Checked = True Then
           ytcampname.Enabled = True
           Ytcamptextbox.Enabled = True
       End If



I am a newbie, so i know i have done something wrong, please correct me.
Posted
Updated 3-Sep-15 7:00am
v2
Comments
Sergey Alexandrovich Kryukov 3-Sep-15 13:08pm    
System.Windows.Forms? Anything else?
—SA

1 solution

First of all, If RadioButton2.Checked = True is not, formally speaking, a bug, but is more than pointless; it should rather be
VB
If RadioButton2.Checked Then '...

Moreover, it can be something like
VB
ytcampname.Enabled = Not RadioButton2.Checked
' and so on...


Checked is already Boolean, no need to compare it with a Boolean constant true or false.

As to your functionality, it does what you have written, not anything else. You try to control Enabled property, not visibility. If you want to change visibility, modify Visible property.

Too bad you did not specify what exactly UI framework/library you are using. If this is System.Windows.Forms, System.Windows.Forms.Control.Visible should be used. If not, it will be something similar.

—SA
 
Share this answer
 
v2

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