当前位置:网站首页>The use of C# control CheckBox
The use of C# control CheckBox
2022-07-31 13:15:00 【dusk and starry sky】
Use the CheckBox control
Today, I used the CheckBox control, record it here.
Tools: Visual Studio 2017 (other versions also work)
Method/step:
1. Drag the CheckBox control to the window, as shown in the following figure:
2. Change the name of the control to CBox
3. Common methods of this control:
this.CheckBox.Checked = true; //Set the control state to checked
this.CheckBox.Checked= false; //Set the control state to unchecked
//or
this.CheckBox.CheckState = CheckState.Checked; //Set the control state to checked
this.CheckBox.CheckState =CheckState.Unchecked; //Set the control state to unchecked
4. How to judge the current state of the control
this.CBox.Checked
if(this.CBox.Checked==ture)
{
MessageBox.Show("Choose");
}
else
{
MessageBox.Show(“No Choose”);
}
5. Double-click the control, an event will be added (when the state of the control changes)
At this time, a function related to the attribute will be generated, and the related function can be realized by editing the function, as shown below:
private void CBox_CheckedChanged(object sender, EventArgs e){if (this.CBox.Checked == true){MessageBox.Show("Choose");}else{MessageBox.Show("No Choose");}}
边栏推荐
猜你喜欢
随机推荐
报错:npm ERR code EPERM
【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)
Optimization of five data submission methods
计算机复试面试问题(计算机面试常见问题)
基本语法(一)
How does the SAP ABAP OData service support the $filter (filter) operation trial version
聊聊 SAP 产品 UI 上的消息显示机制
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
NameNode故障处理的两种方法
FIFO深度计算学习记录(汇总)
Ali on three sides: MQ message loss, repetition, backlog problem, how to solve?
matlab as(assert dominance)
centos7安装mysql5.7步骤(图解版)
vivado里那些看不懂的原语
EXCEL如何快速拆分合并单元格数据
0X7FFFFFFF,0X80000000「建议收藏」
Google Chrome(谷歌浏览器)安装使用
Grab the tail of gold, silver and silver, unlock the programmer interview "Artifact of Brushing Questions"
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
查看Mysql数据库版本