HierarchicalCollection<T>.FindRecursive(Predicate<T>) Method
Returns the first element that matches the conditions defined by the specified predicate.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Parameters
Name | Type | Description |
---|---|---|
match | Predicate<T> | A delegate that defines the conditions of the elements to search for. |
Returns
Type | Description |
---|---|
T | The element that matches the conditions defined by the predicate. |
Remarks
The FindRecursive method individually passes elements of the current hierarchical collection to a predicate, and returns the first element that matches the predicate. A predicate is a delegate to a method that returns true
if the object passed to it matches the conditions defined in the delegate; otherwise the method returns false
.
Example
The code sample below demonstrates how you can find and select a node by custom conditions using the FindRecursive method. In this sample, a node is searched by its url (or a part of url) that is entered in a text box.
using DevExpress.Web.ASPxTreeView;
...
protected void btn_FindNode_Click(object sender, EventArgs e) {
if (ASPxTextBox1.Text != "") {
ASPxTreeView1.SelectedNode = ASPxTreeView1.Nodes.FindRecursive(FindInUrl);
}
}
public bool FindInUrl(TreeViewNode node) {
return node.NavigateUrl.Contains(ASPxTextBox1.Text);
}