TreeListView.AddingNewNode Event
Occurs before a new node is added to the GridControl and allows you to initialize the new record.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Event Data
The AddingNewNode event's data class is TreeListAddingNewEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
NewObject | Gets or sets the object to be added to the binding list. Inherited from AddingNewEventArgs. |
ParentNode | A parent node. |
Remarks
The AddingNewNode event occurs before the GridControl adds a new record to your data source. In this event handler, you can specify a data object and initialize its values.
<dxg:GridControl>
<dxg:GridControl.View>
<dxg:TableView x:Name="view"
KeyFieldName="ID"
ParentFieldName="ParentID"
NewItemRowPosition="Top"
AddingNewNode="view_AddingNewNode"/>
</dxg:GridControl.View>
</dxg:GridControl>
void view_AddingNewNode(object sender, DevExpress.Xpf.Grid.TreeList.TreeListAddingNewEventArgs e) {
e.NewObject = new Employee() {
ID = view.TotalNodesCount + 1,
Name = "",
Department = "Finance",
Position = "Manager"
};
}
Note
The AddingNewNode event does not fire when you add a new node directly to a bound data source.
If you want to maintain a clean MVVM pattern and specify a new data record in a View Model, create a command and bind it to the AddingNewNodeCommand property.
Refer to the following help topic for more information: Add and Remove Rows.