简体   繁体   中英

Display or do not display text box based on check box in C#

Do you guys have any idea on doing a winform that will detect the checkbox to see whether it will display a text box or not? For example, if the checkbox is checked, there will be a textbox. If the checkbox is unchecked, the textbox will disappear.

In your checkbox checked event handler...

textBox1.Visible = checkBox1.Checked;

..if you want it the other way around, you can do this:

textBox1.Visible = !checkBox1.Checked;

Note the exclamation mark, which means "not".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM