//查找可见项
... {
//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.10
TreeNode Node;
str = str.ToUpper();
if (StartNode == null)
...{
Node = tv.Nodes[0];
}
else
...{
Node = StartNode.NextVisibleNode;
}
String Text;
int p;
while (Node != null)
...{
Text = Node.Text.ToUpper();
p = Text.IndexOf(str);
if (p > -1)
...{
return Node;
}
Node = Node.NextVisibleNode;
}
return null;
}
//查找所有项
//Accurately是否为精确查找
private TreeNode GetNode(TreeView tv, TreeNode StartNode, string str, bool accurately)
{
//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.10
TreeNode Node;
if (str == null) return null;
str = str.ToUpper();
if (StartNode == null)
{
Node = tv.Nodes[0];
}
else
{
Node = StartNode.NextVisibleNode;
}
String Text;
int p;
TreeNode ParentNode = Node;
while (Node != null)
{
if (accurately)
{
if (str == Node.Text)
return Node;
}
else
{
Text = Node.Text.ToUpper();
p = Text.IndexOf(str);
if (p > -1)
{
return Node;
}
}
if (Node.GetNodeCount(true) > 0) //有子
{
ParentNode = Node;
Node = Node.Nodes[0];
}
else
{
Node = Node.NextNode;
while ((Node == null) && (ParentNode != null))
{
Node = ParentNode.NextNode;
ParentNode = ParentNode.Parent;
}
}
}
return null;
}