TreeList.AppendNode(Object, Int32, Int32, Int32, Int32, CheckState) Method

Appends a new node with the specified settings.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public virtual TreeListNode AppendNode(
    object nodeData,
    int parentNodeId,
    int imageIndex,
    int selectImageIndex,
    int stateImageIndex,
    CheckState checkState
)
Public Overridable Function AppendNode(
    nodeData As Object,
    parentNodeId As Integer,
    imageIndex As Integer,
    selectImageIndex As Integer,
    stateImageIndex As Integer,
    checkState As CheckState
) As TreeListNode

Parameters

Name Type Description
nodeData Object

An array of values or a DataRow object, used to initialize the created node's cells.

parentNodeId Int32

An integer value that identifies the parent node.

imageIndex Int32

A zero-based index of the image displayed within the node.

selectImageIndex Int32

A zero-based index of the image displayed within the node when it is focused or selected.

stateImageIndex Int32

An integer value that specifies the index of the node's state image.

checkState CheckState

The node's check state.

Returns

Type Description
TreeListNode

A TreeListNode object that represents the added node.

Remarks

To learn more, see Nodes.

Examples

The following code shows how to manually populate a TreeList control with nodes in unbound mode.

To add nodes in unbound mode, utilize the TreeList.AppendNode method. Data that is passed to this method must match the TreeList columns. So, the TreeList columns are created before the nodes are created.

Note that calls to the methods used to create nodes are wrapped with the TreeList.BeginUnboundLoad and TreeList.EndUnboundLoad methods. This reduces the control's updates to a minimum, and thus improves performance.

The following image displays the result.

TreeList.AppeandMode_ex

using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;

private void Form1_Load(object sender, EventArgs e) {
    CreateColumns(treeList1);
    CreateNodes(treeList1);
}

private void CreateColumns(TreeList tl) {
    // Create three columns.
    tl.BeginUpdate();
    TreeListColumn col1 = tl.Columns.Add();
    col1.Caption = "Customer";
    col1.VisibleIndex = 0;
    TreeListColumn col2 = tl.Columns.Add();
    col2.Caption = "Location";
    col2.VisibleIndex = 1;
    TreeListColumn col3 = tl.Columns.Add();
    col3.Caption = "Phone";
    col3.VisibleIndex = 2;
    tl.EndUpdate();
}

private void CreateNodes(TreeList tl) {
    tl.BeginUnboundLoad();
    // Create a root node .
    TreeListNode parentForRootNodes = null;
    TreeListNode rootNode = tl.AppendNode(
        new object[] { "Alfreds Futterkiste", "Germany, Obere Str. 57", "030-0074321" }, 
        parentForRootNodes);
    // Create a child of the rootNode
    tl.AppendNode(new object[] { "Suyama, Michael", "Obere Str. 55", "030-0074263" }, rootNode);
    // Creating more nodes
    // ...
    tl.EndUnboundLoad();
}
See Also