Moving Row Focus

  • 3 minutes to read

This topic provides information on the methods that enable you to move row focus. These methods move focus by a specified number of rows forward or backward. If you need to focus particular rows, please refer to the Focusing Cells topic that provides general information about determining the focused cell and moving focus between Views, rows and columns.

Moving Row Focus

Generally, you will use the methods listed in the table below to move row focus. All these methods are declared by the ColumnView class and thus supported by all View types currently available in XtraGrid.

Method Description
ColumnView.MoveFirst Moves focus to the first visible row within the View.
ColumnView.MoveNext Moves focus to the row following the one currently focused.
ColumnView.MovePrev Moves focus to the row preceding the one currently focused.
ColumnView.MoveNextPage Moves focus forward by the number of rows displayed within the View.
ColumnView.MovePrevPage Moves focus backward by the number of rows displayed within the View.
ColumnView.MoveLast Moves focus to the last row within the View.
ColumnView.MoveLastVisible Moves focus to the last visible row (the last row that is not hidden within a collapsed group).
ColumnView.MoveBy Moves focus by the specified number of rows.

Note that all the methods above, except for the ColumnView.MoveLast method, move focus among visible rows only. This implies that calling these methods will not expand collapsed group rows when using Grid Views. For information on custom navigation through group rows together with their children, please refer to the Working with Groups in Code topic. Note also that the methods in the table above don't allow you to move focus to child or parent Views. For instance, calling the ColumnView.MoveNext method when an expanded master row is focused will focus the next master row within the same View. To learn how to navigate through master and detail rows, please refer to the Master-Detail Relationships and Working with Master-Detail Relationships in Code topics.

One more important member that supports row focus movement is the ColumnView.FocusedRowHandle property. This identifies the currently focused row within a View. For instance, you can increment or decrement the ColumnView.FocusedRowHandle property to move focus to the next or the previous row within a View.

The table below lists additional members that may be useful for you when moving row focus. These members enable you to determine whether the currently focused row is the first or last within a View and thus stop focus movements when such rows are reached. If you implement your own controls for row focus movement, you can use the members below to determine when such controls should be disabled.

Member Description
ColumnView.IsFirstRow Returns true if the currently focused row is the first within a View.
ColumnView.IsLastRow Returns true if the currently focused row is the last data row within a View.
ColumnView.IsLastVisibleRow Returns true if the currently focused row is the last visible within a View.
BaseView.RowCount Returns the total number of visible rows within a View.
BaseView.DataRowCount Returns the number of data rows within a View. Compare this value to the ColumnView.FocusedRowHandle property to determine whether or not the currently focused row is the last row within a View.
See Also