- 2 minutes to read
Adding rows is only possible if the grid's data source allows adding data items. For example, if the grid is bound to a data source that implements the System.ComponentModel.IBindingList interface, the capability to add rows depends on the boolean IBindingList.AllowNew setting.
New Item Row
The New Item Row allows end-users to add new records. It can be displayed above or below all data and group rows depending on the GridControl.NewItemRowPosition property value. By default, the New Item Row is hidden (the GridControl.NewItemRowPosition property is set to NewItemRowPosition.None).
When an end-user starts editing the New Item Row, the GridControl.InitNewRow event is raised. You can handle this event to initialize required fields within the new record. For instance, you can assign a unique value to the key field and/or assign default field values.
Handle the GridControl.AddingNewRow event to customize the new data item initialization.
Adding Rows in Code
The GridControl.AddNewRow method adds an empty row to the grid. If the New Item Row is enabled, this method moves focus to this element. Otherwise, the new record is temporarily placed below existing records. After an end-user has entered cell values and the row has been accepted, the new row moves to its final location according to the current filtering, grouping and sorting settings.