当前位置:网站首页>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");
}
}
边栏推荐
猜你喜欢
随机推荐
Character Functions and String Functions
vivado里那些看不懂的原语
2022年最新重庆建筑安全员模拟题库及答案
sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
函数递归1.0
Encapsulation of conversion between Json and objects (Gson)
电商rpa是什么意思?跟电商rpi是一个意思吗?
行业案例 | 全面防护 赛宁助力能源工控安全建设
榕树贷款GPU 硬件架构
Cognitive-exercise rehabilitation medical robot application design
Optimization of five data submission methods
Hard disk partition, expand disk C, no reshipment system, not heavy D dish of software full tutorial.
NameNode (NN) 和SecondaryNameNode (2NN)工作机制
一文吃透哈希表
[core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
go中select语句
golang中使用泛型
纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据









