Back to Devexpress

TreeListNode.Id Property

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-77488df1.md

latest5.7 KB
Original Source

TreeListNode.Id Property

Gets the index of the corresponding record within the associated data source.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
public int Id { get; }
vb
<Browsable(False)>
Public ReadOnly Property Id As Integer

Property Value

TypeDescription
Int32

An integer value representing the zero-based index of the corresponding data source record.

|

Remarks

The TreeList control synchronizes its displayed data with its data source if the object it is bound to supports the IBindingList interface. This interface provides a ListChanged event which allows you to respond to data source changes. The changed data source record is identified by its index in this event. The Id property of nodes represents namely this index and thus is used to synchronize data source changes with nodes.

Nodes can be obtained by their IDs via the TreeList.FindNodeByID method call.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Id 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-virtual-mode/CS/ExampleMainForm.cs#L78

csharp
{
    if (e.Node.Id < imageListForTree.Images.Count)
    {

winforms-treelist-copy-nodes-to-another-treelist/CS/CopyNodesExample/MainForm.cs#L14

csharp
for (int i = 1; i < 5; i++) {
    int parentId = treeList1.AppendNode(new object[] { $"{i}" }, -1).Id;
    for (int j = 1; j < 4; j++) {

winforms-treelist-customize-cell-tooltip/CS/Form1.cs#L27

csharp
object cellInfo = new TreeListCellToolTipInfo(hit.Node, hit.Column, null);
string toolTip = string.Format("{0} (Column: {1}, Node ID: {2})", hit.Node[hit.Column], hit.Column.FieldName, hit.Node.Id);
e.Info = new DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip);

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

csharp
if (e.ImageIndex == 0)
    if (e.Node.Id > Tree.FocusedNode.Id)
        e.ImageIndex = 2;

winforms-treelist-virtual-mode/VB/ExampleMainForm.vb#L58

vb
Private Sub treeList1_GetSelectImage(ByVal sender As Object, ByVal e As GetSelectImageEventArgs)
    If e.Node.Id < imageListForTree.Images.Count Then
        e.NodeImageIndex = e.Node.Id

winforms-treelist-copy-nodes-to-another-treelist/VB/CopyNodesExample/MainForm.vb#L15

vb
For i = 1 To 4
    Dim parentId = treeList1.AppendNode((New Object() {$"{i}"}), -1).Id

winforms-treelist-customize-cell-tooltip/VB/Form1.vb#L27

vb
Dim cellInfo As Object = New TreeListCellToolTipInfo(hit.Node, hit.Column, Nothing)
Dim toolTip As String = String.Format("{0} (Column: {1}, Node ID: {2})", hit.Node(hit.Column), hit.Column.FieldName, hit.Node.Id)
e.Info = New DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip)

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

vb
If e.ImageIndex = 0 Then
    If e.Node.Id > Tree.FocusedNode.Id Then
        e.ImageIndex = 2

See Also

FindNodeByID(Int32)

FindNodeByKeyID(Object)

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace