【发布时间】:2014-08-04 17:49:28
【问题描述】:
在这种方法中,我在 TreeNodes 中进行搜索:
private void FindByText()
{
TreeNodeCollection nodes = treeView1.Nodes;
foreach (TreeNode n in nodes)
{
FindRecursive(n);
}
}
还有 FindRecursive:
private void FindRecursive(TreeNode treeNode)
{
foreach (TreeNode tn in treeNode.Nodes)
{
string result = Regex.Replace(tn.Text, @"^\d*\.\s*", string.Empty);
if (tn.Text.Contains(this.txtNodeTextSearch.Text))
{
tn.BackColor = Color.Yellow;
tn.EnsureVisible();
count++;
label11.Text = count.ToString();
}
FindRecursive(tn);
}
}
在我所做的 FindRecursive 方法中:
tn.EnsureVisible();
但是,例如,如果我搜索并找到 20 个项目,它将向下滚动并显示最后找到的项目。 然后我需要向上浏览以查看它找到的其他项目。
我需要它像 tn.EnsureVisible();但会指向顶部的第一个项目,如果我愿意,我会向下滚动查看其他项目。
【问题讨论】: