windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-baserow-151dcbb5.md
Gets or sets the row’s index within a collection of rows located at the same level (sibling rows).
Namespace : DevExpress.XtraVerticalGrid.Rows
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
[Browsable(false)]
public int Index { get; set; }
<Browsable(False)>
Public Property Index As Integer
| Type | Description |
|---|---|
| Int32 |
A zero-based index value representing the position of a specific row within a VGridRows collection.
|
This property provides a row’s indexed position within the sibling rows collection represented by a VGridRows object. Row indexes are zero-based. You can use this property either to obtain the row index or reposition the row to a different location within the collection it belongs to.
The Index property value can be used to access a specific row via the collection’s VGridRows.Item property.
The following example switches the position of two rows in the grid’s VGridControlBase.Rows collection of root level rows. The first row moves down to the last position in the rows collection, while the last one moves up to the first position. The BaseRow.Index property is used for this purpose.
The image below displays the look & feel of a grid control before and after execution of the sample code.
using DevExpress.XtraVerticalGrid.Rows;
private void SwitchUtmostRows() {
// saving the last row object in a variable
BaseRow row = vGridControl1.Rows[vGridControl1.Rows.Count - 1];
// moving the first row to the end of the collection
vGridControl1.Rows[0].Index = vGridControl1.Rows[vGridControl1.Rows.Count - 1].Index;
// moving the former last row to the beginning of the collection
row.Index = 0;
}
Imports DevExpress.XtraVerticalGrid.Rows
Private Sub SwitchUtmostRows()
' saving the last row object in a variable
Dim Row As BaseRow = VGridControl1.Rows(VGridControl1.Rows.Count - 1)
' moving the first row to the end of the collection
VGridControl1.Rows(0).Index = VGridControl1.Rows.Count - 1
' moving the former last row to the beginning of the collection
Row.Index = 0
End Sub
See Also