Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Data Binding
   [Expand]Views
   [Collapse]Data Editing and Validation
    [Expand]ErrorInfo Support
     Add and Remove Rows
     Modify and Validate Cell Values
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
    Scrolling
   [Expand]Batch Modifications
   [Expand]Hit Information
    Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Add and Remove Rows

Expanded Common Requirements

You and your end-users can add and remove Data Grid rows only if its underlying data source allows for such an action. For example, the ExcelDataSource is a read-only data source; thus, data editing in a grid bound to this source is not available. Similarly, if a Data Grid is bound to a data source that implements the System.ComponentModel.IBindingList interface, the row operations' availability depends on boolean IBindingList.AllowNew and IBindingList.AllowRemove settings.

Expanded New Item Row

The Data Grid can display an empty row that end-users utilize to add new records. This row is identified by an asterisk (*) displayed within a corresponding row indicator cell. To cancel adding a new row, press Esc.

Demos: Table View | Use New Item Row to add rows | Init newly added rows in a custom manner

Related API

  • GridOptionsView.NewItemRowPosition - allows you to enable a new item row and select whether it should anchor to the View's top or bottom edge.
  • ColumnView.InitNewRow - fires whenever a new record is being added by an end-user. Handle this event to facilitate user input. For example, the code snippet below automatically inserts the current date into a new row cell that belongs to the "Date" column.
  • GridControl.NewItemRowHandle - a constant that specifies the row handle for the New Item Row.

Expanded Data Navigator

The Data Navigator is an embedded toolbar that allows end-users to navigate through Data Grid records and add/remove rows.

Related API

Expanded External Control Navigator

The Data Navigator is a ControlNavigator object displayed directly within a Data Grid. If needed, you can create a standalone Control Navigator and position it anywhere outside your Grid. Utilize the navigator's ControlNavigator.NavigatableControl property to bind the navigator to a Data Grid. The Control Navigator can also navigate through records of the Tree List and Vertical Grid controls.

Expanded Add and Remove Rows in Code

  • Modifying the underlying data source
    If your data source supports adding and removing records, you can use a data source API to modify Grid rows. If a data source does not implement the System.ComponentModel.IBindingList interface, it does not send add/remove notifications to a Data Grid. In this case, you need to update the Data Grid manually by calling the GridControl.RefreshDataSource (updates main Grid view) or BaseView.RefreshData (updates this particular view) methods. The GridOptionsNavigation.AutoFocusNewRow property allows the Data Grid to automatically focus new records added to a data source. The code below adds a new record to a BindingList object that serves as a data source for a Data Grid. Since this data source supports update notifications, you don't need to refresh the Data Grid manually.

  • ColumnView.AddNewRow
    Adds a blank row to the Data Grid. If the New Item Row is enabled, this method moves 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 Data Group filtering, grouping and sorting settings. To accept a new row manually, call the ColumnView.UpdateCurrentRow method from code. The following code shows how to add a new row to a data group. It is assumed that data within a Grid View is grouped against one or more columns. The row is added to the same group as the currently focused row.

  • ColumnView.DeleteRow
    Removes a data record or a group row from the View. If a data source contains multiple tables with master-detail relationships, this method removes a row together with its associated child rows. The code snippet below illustrates how to remove a currently focused row when end-users press the Ctrl+Del shortcut.

  • ColumnView.DeleteSelectedRows
    If the ColumnViewOptionsSelection.MultiSelect property is enabled, end-users can select multiple Data Grid rows (or row cells, depending on the current GridOptionsSelection.MultiSelectMode setting). The DeleteSelectedRows method removes all selected rows and all rows with selected cells if individual cell selection is enabled.

Demos: Remove rows with the Ctrl+Delete shortcut | Prevent a row from being deleted

How would you rate this topic?​​​​​​​