VGridRows.Add(BaseRow) Method

Adds a specific row to the end of the rows collection and returns its index.

Namespace: DevExpress.XtraVerticalGrid.Rows

Assembly: DevExpress.XtraVerticalGrid.v20.1.dll


public virtual int Add(
    BaseRow row
Public Overridable Function Add(
    row As BaseRow
) As Integer


Name Type Description
row BaseRow

An instance of the BaseRow class descendant representing the row to add.


Type Description

The zero-based index at which a specific row object has been added to the collection.


Use the Add method to append the existing row object derived from the BaseRow class to the end of the rows collection represented by the VGridRows object.

The Add method returns the index of the newly added row object in the rows collection. The returned index is zero-based.

To add a set of row objects to the rows collection, it is best to use the VGridRows.AddRange method. If you choose to use the Add method to add a number of rows to the rows collection, use the VGridControlBase.BeginUpdate method to prevent the grid from being repainted each time an item is added. Use the VGridControlBase.EndUpdate method to repaint the control after all items have been added. You can use the VGridRows.Insert method to specify the location where a row object is added.

To remove the row you previously added, use its Dispose method or the VGridRows.Remove method of the collection. Use the Clear() method if you want to remove all rows from the collection.


The following example creates a row object of the EditorRow type and uses the VGridRows.Add method to add the row either to the child rows collection of the JobDescription row or to the grid's collection of top level rows depending upon the JobDescription row's visibility.

using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;

private void AddRow() {
    // creating a row object bound to a specific field and specifying its caption
    EditorRow row = new EditorRow("job_lvl");
    row.Properties.Caption = "Job Level";

    if (vGridControl1.Rows["JobDescription"].Visible) 
        // appending the row to collection of JobDescription row's children
        // appending the row to collection of top level rows
See Also