Ok, I have a text box that the users can input an organization. Once they click search there is a method that loops through the tree to find any node that contains the value entered in the text box. There could be occurences where multiple nodes in the tree contain what the user enters, however, the search stops and the first one found from the top. I would like to add the functionality to enable the user to click search again and the next tree node that contains the search value would be selected, rather than the first node encountered that contains the value.
Here is the code I have to I currently use to accomplish the first part. The Search button's on_click event is SearchButton_Click. I'm using Q1 2009.
Here is the code I have to I currently use to accomplish the first part. The Search button's on_click event is SearchButton_Click. I'm using Q1 2009.
private void FindRecursive(RadTreeNode treeNode, string searchString, Boolean foundFirst) |
{ |
Boolean found = foundFirst; |
foreach (RadTreeNode tn in treeNode.Nodes) |
{ |
if (tn.Text.ToUpper().Contains(searchString) && (!found)) |
{ |
found = true; |
tn.Selected = true; |
tn.Focus(); |
} |
FindRecursive(tn, searchString.ToUpper(), found); |
} |
} |
protected void SearchButton_Click(object sender, EventArgs e) |
{ |
if (Org_Emp_Srch.Text.Trim() != "") |
{ |
string SearchStr = Org_Emp_Srch.Text.ToUpper(); |
FindRecursive(radtreeview1.Nodes[0], SearchStr, false); |
} |
radtreeview1.ExpandAllNodes(); |
} |