Skip to main content
Tab

TreeViewNodeCollection.FindByText(String) Method

Returns a node object with the specified TreeViewNode.Text property value.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public TreeViewNode FindByText(
    string text
)

Parameters

Name Type Description
text String

A String value representing the TreeViewNode.Text property value of the required node.

Returns

Type Description
TreeViewNode

A TreeViewNode object with a specific value of the TreeViewNode.Text property.

Remarks

Use this method to obtain a node, specified by a unique name, assigned to its TreeViewNode.Text property.

Example

This example shows how to create a simple tree when the ASPxTreeView functions in unbound mode. New nodes are added to the ASPxTreeView via the TreeViewNodeCollection.Add method.

The image below shows the result:

TreeView - Creating nodes in code

<dx:ASPxTreeView ID="ASPxTreeView1" runat="server" AllowSelectNode="True">
</dx:ASPxTreeView>
<br />
<dx:ASPxTextBox ID="ASPxTextBox1" runat="server">
</dx:ASPxTextBox>
<br />
<dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxButton1_Click" Text="Add Node">
</dx:ASPxButton>
public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack) {
         CreateTreeView(); 
        }
    }

    //Create treeview nodes. 
    void CreateTreeView() {
        string[] NodeNames = { "Inbox", "Outbox", "Sent Items", "Deleted Items", "Search Folder" };
        foreach (string Text in NodeNames) {
            ASPxTreeView1.Nodes.Add(Text);
        }
        ASPxTreeView1.Nodes.FindByText("Search Folder").Nodes.Add("Categorized Mail");

    }
    //Add a new child node to the selected node.
    protected void ASPxButton1_Click(object sender, EventArgs e) {
        if ((ASPxTreeView1.SelectedNode != null) && (ASPxTextBox1.Text != "")) {
            ASPxTreeView1.SelectedNode.Nodes.Add(ASPxTextBox1.Text);
        }
    }

}
See Also