TreeView - Node Text Editing

  • Books
    • Arts
    • Biographies
    • Children's Books
    • Cooking
    • History
    • Fiction
    • Mystery
    • Nonfiction
    • Romance
    • Science Fiction
    • Travel
  • Music
  • Movies
  • Software
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB
RadTreeView supports Node Editing - you can simply select a node and press F2 (or click an already selected node) and you will be able to edit the node's text.

You need to enable the AllowNodeEditing property of RadTreeView to be able to edit the nodes.

After you have typed the new text, click outside the tree or press the Enter key. The NodeEdit server event will be fired. There, you can change the text of the node, which is being edited. You should use the RadTreeNodeEditEventArgs event arguments to get the new text, like:

RadTreeNode nodeEdited = e.Node;
string newText = e.Text;
nodeEdited.Text = newText;
Select a node and press F2 to edit its contents or click an already selected node.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page AutoEventWireup="false" CodeFile="DefaultCS.aspx.cs" Inherits="TreeView.Examples.Functionality.NodeEditing.DefaultCS"Language="c#"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-thin">
        <telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1" runat="server" TabIndex="1" AccessKey="T" 
            AllowNodeEditing="True" OnNodeEdit="RadTreeView1_NodeEdit">
            <Nodes>
                <telerik:RadTreeNode Text="Books" Expanded="true">
                    <Nodes>
                        <telerik:RadTreeNode Text="Arts">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Biographies">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Children's Books">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Cooking">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="History">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Fiction">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Mystery">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Nonfiction">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Romance">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Science Fiction ">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Travel">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="Music">
                    <Nodes>
                        <telerik:RadTreeNode Text="Alternative">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Blues">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Children's Music">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Classical">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Country">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Dance">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Folk ">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Hard Rock">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Jazz">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Soundtracks">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="Movies">
                    <Nodes>
                        <telerik:RadTreeNode Text="Action">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Animation">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Classics">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Comedy">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Documentary">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Drama">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Horror">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Musicals">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Mystery">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Westerns">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="Software">
                    <Nodes>
                        <telerik:RadTreeNode Text="Database">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Networking">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Presentation">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Project Management">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Reports">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Spreadsheet">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode Text="Word Processing">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>
    </div>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?