当前位置:网站首页>C#控件CheckBox的使用
C#控件CheckBox的使用
2022-07-31 12:54:00 【黄昏和星空】
CheckBox控件使用
今天使用到了CheckBox控件,在这记录一下。
工具:Visual Studio 2017(其他版本也行)
方法/步骤:
1、将CheckBox控件拖到窗口里面,如下图所示:
2、将该控件的名字改成CBox
3、该控件的常用方法:
this.CheckBox.Checked = true; //设置该控件状态为勾选上
this.CheckBox.Checked = false; //设置该控件状态为未选中
//或者
this.CheckBox.CheckState = CheckState.Checked; //设置该控件状态为勾选上
this.CheckBox.CheckState = CheckState.Unchecked; //设置该控件状态为未选中
4、如何判断现在该控件的状态
this.CBox.Checked
if(this.CBox.Checked==ture)
{
MessageBox.Show(“Choose”);
}
else
{
MessageBox.Show(“No Choose”);
}
5、双击该控件,就会添加一个事件(当该控件状态改变时)
此时会产生一个该属性相关的函数,通过编辑该函数即可实现相关的功能,如下所示:
private void CBox_CheckedChanged(object sender, EventArgs e)
{
if (this.CBox.Checked == true)
{
MessageBox.Show("Choose");
}
else
{
MessageBox.Show("No Choose");
}
}
边栏推荐
- 串的基本概念与操作
- alert(1) (haozi.me)靶场练习
- matlab as(assert dominance)
- 【CPU设计实战】简单流水线CPU设计
- 聊聊 SAP 产品 UI 上的消息显示机制
- Hybrid brain-computer interface system based on steady-state visual evoked potentials and attentional EEG
- LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]
- 基于去噪自编码器的故障隔离与识别方法
- 如何使用StarUML画类图[通俗易懂]
- PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
猜你喜欢
随机推荐
/run/NetworkManager占用空间过大
Talk about the message display mechanism on the SAP product UI
快速学完数据库管理
sqlalchemy determines whether a field of type array has at least one consistent data with an array
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
WPF中TabControl动态获取当前选中的TabItem
FIFO深度计算学习记录(汇总)
Flutter keyboard visibility
NameNode故障处理的两种方法
基于神经网络的多柔性梁耦合结构振动控制
Wearing detection and action recognition of protective gear based on pose estimation
anaconda虚拟环境安装pytorch gpu版本
jmeter性能测试步骤入门(性能测试工具jmeter)
深入浅出边缘云 | 4. 生命周期管理
集群中增加数据节点与退役数据节点
基于姿态估计的护具佩戴检测与动作识别
[Shader] Shader official example [easy to understand]
STM32——软件SPI控制AD7705[通俗易懂]
PHP序列化:eval
Three-Phase PWM Rectifier Predictive Direct Power Control