zoukankan
html css js c++ java
默认选中Treeview的某个节点修正方法
感谢High_Mount指出我的上一篇文章
默认选中TreeView某个节点的方法
中所写的选中Treeview某个节点的方法有错误,只能适用于少于三层的情况,下面我修改这个方法,使它能适用于任意多层。代码如下:
/**/
///
<summary>
///
选中treeview的某个节点,需要每个node的value不同
///
</summary>
///
<param name="sNodeValue"></param>
private
void
selectNode(TreeView tv,
string
sNodeValue)
{
foreach
(TreeNode tRoot
in
tv.Nodes)
{
if
(tRoot.Value
==
sNodeValue)
{
tRoot.Select();
}
else
{
if
(tRoot.ChildNodes
!=
null
)
{
//
foreach (TreeNode tChild in tRoot.ChildNodes)
//
{
//
if (tChild.Value == sNodeValue)
//
tChild.Select();
//
}
TreeNode tTmp
=
null
;
tTmp
=
FindNode(tRoot, sNodeValue);
if
(tTmp
!=
null
)
tTmp.Select();
}
}
}
}
/**/
///
<summary>
///
递归查找父节点
///
</summary>
///
<param name="tnParent">
指定一个根节点,然后遍历它
</param>
///
<param name="strValue">
所要查找的节点的value
</param>
private
TreeNode FindNode(TreeNode tnParent,
string
strValue)
{
if
(tnParent
==
null
)
return
null
;
if
(tnParent.Value
==
strValue)
return
tnParent;
TreeNode tnRet
=
null
;
foreach
(TreeNode tn
in
tnParent.ChildNodes)
{
tnRet
=
FindNode(tn, strValue);
if
(tnRet
!=
null
)
break
;
}
return
tnRet;
}
查看全文
相关阅读:
Permutation Sequence
Sqrt(x)
Search in Rotated Sorted Array ||
[STL]list的erase正确与错误用法
一个支持Git应用编程开发的第三方库(API)
VC++生成full dump文件
Maven构建C++工程的插件-NAR
VC++ Watch窗口查看指针指向的数组
Android SDK更新失败的解决方法
ADT20新建项目Android Support library not installed问题
原文地址:https://www.cnblogs.com/vagerent/p/845691.html
最新文章
一步一步教你做ios推送
iPhone应用程序间传递数据
二、UITableView和它的亲戚们
创建和发布
获取当前位置信息-ios
将16进制颜色转换成UIColor-ios
项目管理的误区:进度正常则代表项目正常
OKR文化:OKR的基本原理
牢记使命让你的公司走的更远
实际工作中,向上反馈的3种技巧(加上1:1会议案例)
热门文章
如何思考增长策略
日周月报该如何选择
如何做好项目的执行与进度控制
Add Binary
[Leetcode]-- Anagrams
Edit Distance
[Leetcode]-- Maximal Rectangle
Maximum Depth of Binary Tree
Swap Nodes in Pairs
Permutations
Copyright © 2011-2022 走看看