如何通过单选按钮隐藏标签和文本框? [英] How to hide label and textbox through Radio Button?

查看:257
本文介绍了如何通过单选按钮隐藏标签和文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望一起显示隐藏文本框和标签。我有2个单选按钮,一个是创建和管理,所以如果我选择创建收音机,它应该显示文本框和标签,当我选择管理时,它应该隐藏这些控件。



我试过这种方式但没有工作。它没有隐藏,只是禁止用户在文本框上写东西。



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.

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







我是新手,所以我知道我有做错了,请c ortif me。




I am a newbie, so i know i have done something wrong, please correct me.

推荐答案

首先,如果RadioButton2.Checked = True 不是,正式来说,错误,但不仅无意义;它应该是

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



此外,它可能类似于


Moreover, it can be something like

ytcampname.Enabled = Not RadioButton2.Checked
' and so on...





已检查已经是布尔值,无需将其与布尔常量true或false进行比较。



至于你的功能,它可以完成你所写的,而不是其他任何东西。您尝试控制已启用属性,而不是可见性。如果要更改可见性,请修改可见属性。



太糟糕了,你没有指定究竟是什么UI框架/您正在使用的库。如果这是 System.Windows.Forms ,则应使用 System.Windows.Forms.Control.Visible 。如果没有,它将是类似的东西。



-SA



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


这篇关于如何通过单选按钮隐藏标签和文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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