All docs
V20.1
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

TreeList.InitNewRow Event

Fires when a new node is about to be created in the New Item Row and allows you to initialize column values.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

[DXCategory("Data")]
public event TreeListInitNewRowEventHandler InitNewRow
<DXCategory("Data")>
Public Event InitNewRow As TreeListInitNewRowEventHandler

Event Data

The InitNewRow event's data class is TreeListInitNewRowEventArgs.

Remarks

The TreeList.InitNewRow event fires when a new row is about to be created and allows you to initialize column values. This event fires if the user starts to enter a value in the New-Item Row or invokes the Add Node or Add Child Node command in the context menu.

See New Item Row for more information.

Examples

The code below shows how to initialize the Status, Start Date, and Due Date column values when a user focuses the New Item Row.

The TreeList.KeyFieldName property specifies the field name that contains node keys. A node's key should be unique and cannot be empty. Since the column that corresponds to the key field is not typically shown in the tree list, the user cannot enter a value.

The code below also shows how to handle the TreeList.InitNewRow event to specify a key for a newly created node. In this example, the tree list uses integer values as node keys and the handler assigns the next available integer to the new node.

private void TreeList1_InitNewRow(object sender, DevExpress.XtraTreeList.TreeListInitNewRowEventArgs e) {
    e.SetValue("Status", 0);
    e.SetValue("StartDate", DateTime.Now);
    e.SetValue("DueDate", DateTime.Now.AddDays(7));
    e.SetValue("ID", treeList1.AllNodesCount);
}
See Also