Tab

TreeViewNode.Parent Property

Gets the immediate parent node to which the current node belongs.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public TreeViewNode Parent { get; }

Property Value

Type Description
TreeViewNode

A TreeViewNode object representing the node's immediate parent.

Remarks

Use the Parent property to identify and access the immediate parent node which owns the current node.

Examples

The sample code below represents an ASPxTreeView.ExpandedChanging event handler. The event handler prevents collapsing nodes if it has selected children in any generation.

View Example

using DevExpress.Web.ASPxTreeView;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ASPxTreeView1_ExpandedChanging(object source, DevExpress.Web.ASPxTreeView.TreeViewNodeCancelEventArgs e) {
        if ((e.Node.Expanded) && (ASPxTreeView1.SelectedNode != null)) {
            TreeViewNode  node = ASPxTreeView1.SelectedNode.Parent;
            while (node != null) {
                if (e.Node == node) {
                    e.Cancel = true;
                    break;
                }
                node = node.Parent;
            }
        }
    }
}
See Also