关键代码:
#region 检查节点文本是否存在 /// <summary> /// 检查节点文本是否存在 /// </summary> /// <param name="tree">TreeView</param> /// <param name="key">节点文本</param> /// <returns>是否存在</returns> public static bool CheckNodeExist(this TreeView tree, string key) { bool _exists = false; for (int i = 0; i < tree.Nodes.Count; i++) { TreeNode _curNode = tree.Nodes[i]; if (string.Compare(_curNode.Text, key, true) == 0) _exists = true; else _exists = CheckNodeExist(tree.Nodes[i], key); } return _exists; } private static bool CheckNodeExist(TreeNode node, string key) { for (int i = 0; i < node.Nodes.Count; i++) { TreeNode _node = node.Nodes[i]; if (string.Compare(_node.Text.Trim(), key, true) == 0) { return true; } if (_node.Nodes.Count > 0) { CheckNodeExist(_node, key); } } return false; } #endregion 检查节点文本是否存在
希望有所帮助!
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
时间: 2024-10-15 20:04:44