ColumnView.FocusedRowHandle Property
Read this property value to retrieve the currently selected row’s handle. Modify the property to manually select a row with the given handle.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
Int32 | An integer value representing the handle of the focused record. |
Remarks
Records within a View (rows in a Grid View and cards in a Card View) are identified by their handles. The FocusedRowHandle property allows to get the currently selected row’s handle, or to move focus to a row with the specific handle. In latter case, the Data Grid expands a group that contains this row, and scrolls the View up or down to make this row visible.
If there is no focused record, the FocusedRowHandle property returns the GridControl.InvalidRowHandle value. For instance, this will be returned when the View is empty. Note that if a Grid View has any records, you cannot set the FocusedRowHandle property to the GridControl.InvalidRowHandle value to de-select a currently focused row.
Note
The FocusedRowHandle method works only when a Grid is completely initialized. If you need to call it when the form loads, call the GridControl.ForceInitialize method first to ensure the control is ready.
Do not use the FocusedRowHandle property to determine whether the Grid control is focused: the Grid returns valid FocusedRowHandle values even when the control itself is not focused.
When row focus changes, the ColumnView.FocusedRowChanged and ColumnView.FocusedRowObjectChanged events are raised.
In Layouts and Card Views, when you change the FocusedRowHandle property value the ColumnView.FocusedColumn property resets to null. In this instance, you may want to manually edit the FocusedColumn property to move focus to a specific card field.
Multiple Row\Card Selection Mode
The focused row\card is the row (card) that accepts input from an end-user. For that reason, a View can have only one focused row even if multiple row (card) selection is on.
In multiple row\card selection mode, a focused row can be unselected (not highlighted) and vice versa, a selected (highlighted) row can be unfocused. The following images illustrate these cases.
The focused “Condiments” row is selected. The ColumnView.GetSelectedRows method returns three row handles, including the focused row handle. | |
The focused “Condiments” row is not selected, selected “Dairy Products” and “Grains, Cereals” rows are not focused. The ColumnView.GetSelectedRows method returns an array that contains two handles and does not include the focused row handle. |
See the Multiple Row and Cell Selection topic for more information.
Note
Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the FocusedRowHandle member must not be invoked for these Views. The FocusedRowHandle 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.
- 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 FocusedRowHandle 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.