Back to Devexpress

TreeList.RootValue Property

windowsforms-devexpress-dot-xtratreelist-dot-treelist-a0554bc3.md

latest5.5 KB
Original Source

TreeList.RootValue Property

Gets or sets the value that identifies root records in the data source. The root records must have the RootValue in the field the ParentFieldName property specifies.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
[DefaultValue(0)]
public object RootValue { get; set; }
vb
<DefaultValue(0)>
Public Property RootValue As Object

Property Value

TypeDefaultDescription
Object0

An object the root nodes contain in the field specified by the TreeList.ParentFieldName property. By default, an integer 0 value.

|

Remarks

The KeyFieldName and ParentFieldName properties specify Key and Parent fields in the bound data source. The Tree List control uses these fields to organize the underlying records into a data hierarchy.

Root nodes must have their Parent Field values set to RootValue (by default, an Integer 0 value).

Important

The RootValue property and values in the KeyFieldName and ParentFieldName fields must be of the same type.

Note

Parent field values are compared to key field values using the Equals method. Note that this method returns different values for different data types, even if the values are the same. For instance, this method returns false if two compared values are the same, but represented by the double and decimal types. So, be sure that the field specified by the TreeList.ParentFieldName property is of the same type as the RootValue property. Otherwise, the tree will be reconstructed each time node values are changed. This may lead to a performance drop, as it causes the focused node and column to be reset, and changes the node order.

See Tree Generation Algorithm in the Tree List to learn more.

The following code snippets (auto-collected from DevExpress Examples) contain references to the RootValue 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.

xpo-how-to-implement-self-referenced-persistent-objects-and-display-them-within-the-xtra-tree-list/CS/CS/Form1.cs#L76

csharp
treeList1.ParentFieldName = "Manager!";
treeList1.RootValue = null;
treeList1.DataSource = xpCollection1;

winforms-treelist-custom-check-nodes-behavior/CS/Example/Main.cs#L25

csharp
customerList.Add(new Customer("Customer" + i, i % levels, recordsID++));
treeList.RootValue = 0;
treeList.ParentFieldName = "ParentID";

xpo-how-to-implement-self-referenced-persistent-objects-and-display-them-within-the-xtra-tree-list/VB/CS/Form1.vb#L64

vb
treeList1.ParentFieldName = "Manager!"
treeList1.RootValue = Nothing
treeList1.DataSource = xpCollection1

winforms-treelist-custom-check-nodes-behavior/VB/Example/Main.vb#L25

vb
Next i
treeList.RootValue = 0
treeList.ParentFieldName = "ParentID"

See Also

KeyFieldName

ParentFieldName

Bound Mode

Tree Generation Algorithm in the Tree List

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace