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.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
row | BaseRow | An instance of the BaseRow class descendant representing the row to add. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index at which a specific row object has been added to the collection. |
Remarks
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.
Example
The example below creates a row. The Rows collection’s Add(BaseRow)
method is called to add this row to the control. The row is added as a top-level row or as JobDescription row’s child depending on a condition.
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
private void AddRow() {
// Create a row bound to a specific field and specify its caption.
EditorRow row = new EditorRow("job_lvl");
row.Properties.Caption = "Job Level";
if (vGridControl1.Rows["JobDescription"].Visible)
// Append the row to the JobDescription row's child row collection.
vGridControl1.Rows["JobDescription"].ChildRows.Add(row);
else
// Append the row to the top-level row collection.
vGridControl1.Rows.Add(row);
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(BaseRow) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.