C# winform treeView checkbox全选反选
private void treeView2_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Action != TreeViewAction.Unknown)
{
CheckAllChildNodes(e.Node, e.Node.Checked);
//选中父节点
bool bol = true;
if (e.Node.Parent != null)
{
for (int i = 0; i < e.Node.Parent.Nodes.Count; i++)
{
if (!e.Node.Parent.Nodes[i].Checked)
bol = false;
}
e.Node.Parent.Checked = bol;
}
}
}
#region 选中子节点
public void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
{
foreach (TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if (node.Nodes.Count > 0)
{
this.CheckAllChildNodes(node, nodeChecked);
}
}
}
#endregion
最新文章
- 设置label上文字大小、颜色不一样 NSMutableAttributedString的使用
- 发布和运行HOLOLENS程序注意这里要勾上,不然就成普通的UWP程序了!
- python计算文件的md5值
- sql case when then else end
- ses_cations 值顺序
- 把CMSampleBufferRef转成Data
- TSkinData 皮肤控件后最大最小提示英文Close的解决方法
- Nginx+PHP-fpm高负载优化及压力测试方法
- 关闭ehcache的更新检查UpdateChecker
- 【zoj2562】反素数
- p标签里面不要放div标签(块元素)
- 【STM32学习笔记1】基于固件库的STM32_MDK工程模版
- SQL SERVER大话存储结构(3)_数据行的行结构
- Python+Selenium webdriver Api
- RBAC权限管理模型 产品经理 设计
- java----javaBean
- [转]VS Code 扩展 Angular 6 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS &; Flex Layout
- TXB0108 TXS0108E 8-Bit Bidirectional Voltage-Level Translator for Open-Drain and Push-Pull Applications
- JMeter学习(二十六)逻辑控制器(转载)
- tnsping 命令解析
热门文章
- WINFORM时间控件(DATATIMEPICKER)的显示格式设置
- oracle11g interval(numtoyminterval())自动创建表分区
- CentOS7 Tomcat 环境部署
- Lintcode 166. 链表倒数第n个节点
- spfa模板
- ppmoney 总结二
- ExtJS 数据模型
- 关于一个parent(),siblings()的小问题
- 从零开始---控制台用c写俄罗斯方块游戏(2)
- (转)java自带线程池和队列详细讲解 - CSDN过天的专栏