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.v24.2.dll
Declaration
Event Data
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. |
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.
Example
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);
}