代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
Treeview 选择实现操作
作者:
CSDN
/ 发布于
2012/1/11
/
853
<div><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> Treeview 选择实现</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">class</span><span style="color: rgb(0,0,0)"> TreeViewCheck { </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 系列节点 Checked 属性控制 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="e"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CheckControl(TreeViewEventArgs e, TreeNodeCollection tv) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (e.Action </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> TreeViewAction.Unknown) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (e.Node </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">&&</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">!</span><span style="color: rgb(0,0,0)">Convert.IsDBNull(e.Node)) { CheckParentNode(e.Node); </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (e.Node.Nodes.Count </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">0</span><span style="color: rgb(0,0,0)">) { CheckAllChildNodes(e.Node, e.Node.Checked); } } } } </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 私有方法</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">改变所有子节点的状态</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CheckAllChildNodes(TreeNode pn, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsChecked) { </span><span style="color: rgb(0,0,255)">foreach</span><span style="color: rgb(0,0,0)"> (TreeNode tn </span><span style="color: rgb(0,0,255)">in</span><span style="color: rgb(0,0,0)"> pn.Nodes) { tn.Checked </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> IsChecked; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (tn.Nodes.Count </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">0</span><span style="color: rgb(0,0,0)">) { CheckAllChildNodes(tn, IsChecked); } } } </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">改变父节点的选中状态,此处为所有子节点不选中时才取消父节点选中,可以根据需要修改</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CheckParentNode(TreeNode curNode) { </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> bChecked </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (curNode.Parent </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">) { </span><span style="color: rgb(0,0,255)">foreach</span><span style="color: rgb(0,0,0)"> (TreeNode node </span><span style="color: rgb(0,0,255)">in</span><span style="color: rgb(0,0,0)"> curNode.Parent.Nodes) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (node.Checked) { bChecked </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">true</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; } } </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (bChecked) { curNode.Parent.Checked </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">true</span><span style="color: rgb(0,0,0)">; CheckParentNode(curNode.Parent); } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { curNode.Parent.Checked </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">; CheckParentNode(curNode.Parent); } } } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> Treeview 选择实现</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">TreeView节点连载</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> tv_RightList_AfterCheck(</span><span style="color: rgb(0,0,255)">object</span><span style="color: rgb(0,0,0)"> sender, TreeViewEventArgs e) { TreeViewCheck.CheckControl(e, tv_selectItem.Nodes); } </span></div>
试试其它关键字
Treeview
操作
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
CSDN
贡献的其它代码
(
27
)
.
xml操作类
.
完全无组件,不用调用Excel.exe 导出数据到Excel
.
DropDownList手动构造一个下拉树形
.
判断是否低于IE6的版本
.
javascript 鼠标拖拉画图
.
取汉字首字母
.
字符串格式化通用类
.
mssql海量高效分页存储过程
.
.net 获取远程IP 得到省市
.
javascript 模仿windows拖动 封装类
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3