Skip to main content

GridView.TopRowIndex Property

Gets or sets the top visible row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid

Declaration

[Browsable(false)]
public int TopRowIndex { get; set; }

Property Value

Type Description
Int32

An integer value representing the index of the top row visible.

Remarks

To scroll the View via code, you can assign a row’s visible index to the TopRowIndex property. The specified row will become the top visible row, if possible. Note that if the GridOptionsBehavior.SmartVertScrollBar option is disabled, any row within the View can be made top visible. For instance, you can assign the last visible row index to the TopRowIndex property and the row will actually become top visible row within the View. If the option mentioned is enabled, the View will be scrolled to the bottom possible position when the bottom visible row is at the bottom of the View.

Changing this property value raises the GridView.TopRowChanged event.

Please refer to the Rows topic for information on obtaining row visible indexes.

Note

In Embedded detail mode, the TopRowIndex property may return unexpected values when a detail View is open and is scrolled. In this case, the TopRowIndex property may refer to rows within detail Views. To check if the referred row belongs to a detail View, use the ColumnView.GetVisibleRowHandle along with the GridView.IsExternalRow method, as shown below:

int rowHandle = gridView1.GetVisibleRowHandle(gridView1.TopRowIndex);
//Check if the row belongs to a detail View:
if(gridView1.IsExternalRow(rowHandle)) {
    //...
}

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the TopRowIndex member must not be invoked for these Views. The TopRowIndex member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

See Also