VGridRows.Item[Int32] Property
Gets a row object from the rows collection at the specified position.
Namespace: DevExpress.XtraVerticalGrid.Rows
Assembly: DevExpress.XtraVerticalGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
index | Int32 | An integer value specifying the desired row’s zero-based index. |
#Property Value
Type | Description |
---|---|
Base |
A Base |
#Remarks
Use this property to obtain a row at the specified location within the rows collection represented by the VGridRows object. The index parameter refers to the row’s BaseRow.Index property. You can use the VGridRows.IndexOf method to locate a row, or you can use the index returned from the VGridRows.Add method.
This property is an indexer for the VGridRows class. It gives the ability to access a specific row in the rows collection by using the following syntax:
vGridControl1.Rows[index].
The index number is zero-based. If the parameter value is negative or exceeds the maximum available index, an exception is raised.
#Example
The following example replaces the last row in the rows collection. This code assumes that a VGridControl and at least one Row object have been instantiated. The example gets the number of rows in the VGridControlBase.Rows collection and replaces the last row with a newly created one. The index value of the row being replaced is set to the Count property, minus one, since the VGridRows collection is zero-based indexed.
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
public void ReplaceLastRow() {
// creating a new row bound to the specified field
EditorRow newRow = new EditorRow("hire_date");
newRow.Properties.Caption = "Hire Date";
// replacing the last row in the collection.
vGridControl1.Rows.Remove(vGridControl1.Rows[vGridControl1.Rows.Count - 1]);
vGridControl1.Rows.Add(newRow);
}