1. 方法
private int TreeviewFindWithText(string text,int startindex)
{
for (int i = startindex; i < treeView1.Nodes[0].Nodes.Count; i++)
{
if (treeView1.Nodes[0].Nodes[i].Text.Trim().Contains(text))
{
return i;
}
// return -1;
}
return -1;
}
2.定义全局变量
int findindex= 0;
3.使用
click方法中
string strText = this.textBox1.Text.Trim();
ListViewItem lvItem = this.listView1.FindItemWithText(strText, true, iSearchIndex);
if (lvItem != null)
{
lvItem.Selected = true;
this.listView1.TopItem = lvItem;
iSearchIndex = lvItem.Index + 1;
if (iSearchIndex >= this.listView1.Items.Count)
{
<pre name="code" class="csharp"> iSearchIndex = 0;
} } else { iSearchIndex = 0; } Text_changed事件中
iSearchIndex = 0;