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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Overview
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Layouts
    [Expand]Binding to Data
    [Expand]Rows
    [Collapse]Records
      Adding and Deleting Records
      Focusing and Scrolling Records
    [Expand]Cells
    [Expand]In-place Editors
     Formatting
    [Expand]Appearances
     Hit Information
    [Expand]Custom Painting
    [Expand]Alpha Blending and Background Images
    [Expand]Customization Form
     Batch Modifications
    [Expand]Drag and Drop
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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.

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