windowsforms-devexpress-dot-xtratreelist-dot-treelist-81390c9a.md
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.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Data")]
public event TreeListInitNewRowEventHandler InitNewRow
<DXCategory("Data")>
Public Event InitNewRow As TreeListInitNewRowEventHandler
The InitNewRow event's data class is TreeListInitNewRowEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ParentNode | Gets the parent node. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| SetValue(Object, Object) | Sets the specified value in the specified column. |
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.
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);
}
Private Sub TreeList1_InitNewRow(ByVal sender As Object, ByVal e As DevExpress.XtraTreeList.TreeListInitNewRowEventArgs) _
Handles treeList1.InitNewRow
e.SetValue("Status", 0)
e.SetValue("StartDate", DateTime.Now)
e.SetValue("DueDate", DateTime.Now.AddDays(7))
e.SetValue("ID", treeList1.AllNodesCount)
End Sub
See Also