GridView.TopRowIndex Property
Gets or sets the top visible row.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v24.2.dll
Declaration
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.
- GridControl.MainView - returns the top most View in a grid;
- GridControl.FocusedView - returns the focused View;
- GridControl.DefaultView - returns the currently maximized View;
- the sender parameter of View specific events;
- GridView.GetDetailView - returns a detail clone View for a specific master row.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the TopRowIndex property.
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.