A newer version of this page is available. Switch to the current version.

GridView.TopRowIndex Property

Gets or sets the top visible row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[Browsable(false)]
public int TopRowIndex { get; set; }
<Browsable(False)>
Public Property TopRowIndex As Integer

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 real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

See Also