[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Collapse]Data Layout: Records, Rows and Cells
      Adding and Deleting Records
      Focus and Scroll Records
     Customization Form
     Data Layout: Records, Rows, and Cells
   [Expand]Data Editing and Validation
    Formatting Values
   [Expand]Drag and Drop
   [Expand]Appearance and Custom Painting
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst 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]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Adding and Deleting Records

This topic covers methods of adding and deleting records in the Vertical Grid Control (VGridControl).

Expanded Adding Records

To add a new record, you can use the VGridControlBase.AddNewRecord method. This method is only supported for data sources implementing the System.ComponentModel.IBindingList interface. In other instances, to add new records you should use methods provided by your data source. After a new record has been added, the vertical grid reflects any changes made to the data source and focuses the new record if the VGridOptionsBehavior.AutoFocusNewRecord property is set to true.

The VGridControlBase.AddNewRecord method adds an empty record to the underlying data source. You can let the end-user to manually fill its cell values or initialize them in code using the VGridControlBase.SetCellValue method or by handling the VGridControlBase.InitNewRecord event.

Expanded Deleting Records

To delete a record from a data source, use the VGridControlBase.DeleteRecord method. This method is only in effect for data sources that support record deletion. The record to delete is identified by its index that is passed as a parameter.

Expanded Adding and Deleting Records Using Methods Provided by a Data Source

When working in bound mode, the most used types of data sources are System.Data.DataTable and System.Data.DataView objects. These objects represent records by means of the System.Data.DataRow and System.Data.DataRowView objects, respectively. The System.Data.DataTable class exposes the collection of such objects via its Rows property. The System.Data.DataView object represents the actual collection of these objects. You can use methods that add or remove objects from these collections to add and delete data source records.

The following example demonstrates how to add a new record to the data source which is represented by the System.Data.DataTable object.

The next example demonstrates how to add records when a data source is represented by a System.Data.DataView object.

To delete a record, you can use the DataTable.Rows.RemoveAt and DataView.Delete methods depending on the data source's type. The following code handles the vertical grid's KeyDown event to delete the currently focused record when the CTRL+DELETE combination is pressed.

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