[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Collapse]Data Editing and Validation
     Add and Remove Rows
    [Expand]Modify Cell Values
    [Expand]Input Validation
    [Expand]Clipboard Management
     Examples
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Add and Remove Rows

Expanded New Item Row

End users can use the New Item Row to add new records:

To show the New Item Row, set the TableView.NewItemRowPosition property to NewItemRowPosition.Top or NewItemRowPosition.Bottom.

End users can cancel appending a new row by pressing the Esc key while the row is focused. The new row is automatically added to the data source and a blank new item row is displayed if the row's data is valid and focus has been moved to another row.

Note

The TreeList View does not currently support a UI for adding new nodes.

The following properties allow you to customize New Item Row:

Property Description
ColumnBase.NewItemRowCellStyle Specifies a style for the column's cell displayed within the New Item Row.
TableView.NewItemRowCellStyle Specifies a common style for all data cells displayed within the New Item Row.
Note

You can apply the NewItemRowCellStyle only to the data cells of the New Item Row displayed at the top of the TableView, i.e., the TableView.NewItemRowPosition property is set to NewItemRowPosition.Top.

Expanded Add and Remove Rows In Code

Add New Rows

Use the following methods to add a new row:

Method Description
TableView.AddNewRow Adds a new row to the TableView's underlying datasource.
TreeListView.AddNewNode Adds a new node to the TreeListView's underlying datasource.

These methods add a blank row to the view's datasource. If the New Item Row is enabled, these methods move focus to this element. Otherwise, the new record is temporarily placed below the 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.

Initialize New Rows

You can handle the following events to initialize the required fields within the new record:

Event Description
GridViewBase.AddingNewRow Occurs before adding a new row to a data grid and allows you to initialize the new record.
TreeListView.AddingNewNode Occurs before adding a new node to a data grid and allows you to initialize the new record.
TableView.InitNewRow Allows you to initialize a new row with default values.
TreeListView.InitNewNode Allows you to initialize a new node with default values.

Using these events you can set row values. Refer to the Obtain and Set Cell Values topic to learn more.

Remove Rows

Use the GridViewBase.DeleteRow method to remove a data row. The data row is identified by its handle - a non negative integer value. Refer to Obtaining Row Handles for information on how to obtain row handles.

The example below shows how to remove rows using a grid command:

Expanded See Also

Is this topic helpful?​​​​​​​