Back to Devexpress

TreeListNode.Tag Property

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-6f613895.md

latest4.2 KB
Original Source

TreeListNode.Tag Property

Gets or sets the data associated with a Tree List node.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Data")]
public virtual object Tag { get; set; }
vb
<DefaultValue(Nothing)>
<DXCategory("Data")>
Public Overridable Property Tag As Object

Property Value

TypeDefaultDescription
Objectnull

An object containing information associated with the Tree List node.

|

Remarks

This property can be used to store any object that you want to associate with a node.

Example

The following example demonstrates a way to traverse through root nodes. A Boolean value is assigned to the TreeListNode.Tag property of each visited node. Odd nodes get a true property value, while even nodes get a false value.

csharp
bool oddRow = false;
for(int i = 0; i < treeList1.Nodes.Count; i++) {
   treeList1.Nodes[i].Tag = oddRow;
   oddRow = ! oddRow;
}
vb
Dim oddRow As Boolean = False
Dim I As Integer
For I = 0 To TreeList1.Nodes.Count - 1
   TreeList1.Nodes(I).Tag = oddRow
   oddRow = Not oddRow
Next

The following code snippets (auto-collected from DevExpress Examples) contain references to the Tag property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-treelist-dynamic-load-nodes-unbound-mode/CS/TreeList-UnboundMode-ViaBeforeExpandEvent/Form1.cs#L100

csharp
if (node.HasChildren)
        node.Tag = true;
}

winforms-treelist-create-file-manager-drag-drop-files-folders/CS/FileList/FileListHelper.cs#L103

csharp
if (node.HasChildren)
        node.Tag = true;
}

winforms-treelist-dynamic-load-nodes-unbound-mode/VB/TreeList-UnboundMode-ViaBeforeExpandEvent/Form1.vb#L86

vb
node.HasChildren = HasFiles(s)
    If node.HasChildren Then node.Tag = True
Catch

winforms-treelist-create-file-manager-drag-drop-files-folders/VB/FileList/FileListHelper.vb#L84

vb
node.HasChildren = HasFiles(s)
    If node.HasChildren Then node.Tag = True
Catch

See Also

Nodes

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace