当前位置:网站首页>复选框的基本使用与实现全选和反选功能
复选框的基本使用与实现全选和反选功能
2022-06-23 07:53:00 【Scarlett2025】
Checked属性,标记当前复选框状态(选中时为True否则False)
ThreeState 会提供三种选中状态
根据CheckState来判断(Checked[选中] , Unchecked[没选中] , Indeterminate[树结构时,会出现的一种状态,表示当前树结构下有一个或多个子项(并不是所有子项)被选中])
CheckedChanged 事件:指示当前控件是否被选中
页面布局如下:

双击【全部选中】按钮,代码如下:
private void AllSelected_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.Controls.Count; i++)
{
CheckBox cb = this.Controls[i] as CheckBox; //等同
//解决方法1 ,判断cb是否为null.
if (cb != null)
{
cb.Checked = true;
}
}
}双击【取消全选】按钮,代码如下:
private void CancelAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.Controls.Count; i++)
{
CheckBox cb = this.Controls[i] as CheckBox;
//解决方法2,判断当前控件的type
if (this.Controls[i].GetType() == typeof(CheckBox))
{
cb.Checked = false;
}
}
}边栏推荐
- 顺序表课设
- 正则表达式使用案例
- MySQL common skills
- Google common syntax
- 深度学习------不同方法实现lenet-5模型
- Markdown learning
- Take you to tiktok. That's it
- Introduction to Excel VBA and practical examples
- Capturing packets to find repeated acks and a large number of TCP retransmissions in TCP sessions -- sack (selective acknowledgement) technology
- Openvino series 19 Openvino and paddleocr for real-time video OCR processing
猜你喜欢

What are open source software, free software, copyleft and CC? Can't you tell them clearly?

How to start Jupiter notebook in CONDA virtual environment

11 字符串函数

AVL树的实现

数据资产为王,解析企业数字化转型与数据资产管理的关系

openvino系列 19. OpenVINO 与 PaddleOCR 实现视频实时OCR处理

socket编程(多进程)

INT 104_LEC 06

Deep learning ----- different methods to realize vgg16

PHP file contains -ctf
随机推荐
建立一有序的顺序表,并实现下列操作: 1.把元素x插入表中并保持有序; 2.查找值为x的元素,若找到将其删除; 3.输出表中各元素的值。
After easynvr video is enabled, no video file is generated. How to solve this problem?
MySQL slow query record
Ad object of Active Directory
Markdown学习
Using jetpack datastore for data storage
php序列化和反序列化-ctf
openni. utils. OpenNIError: (OniStatus.ONI_STATUS_ERROR, b‘DeviceOpen using default: no devices found‘
Deep learning ----- convolution (conv2d) bottom layer
Configuration asmx not accessible
transform的结构及用法
Vulnhub | DC: 3 |【实战】
Vulnhub | DC: 4 | [combat]
vtk.js鼠标左键滑动改变窗位和窗宽
PHP file contains -ctf
Cloud computing "half peak"
MySQL common skills
Learn to draw Er graph in an article
Tensorboard的使用
socket编程(多进程)