ColumnView.FocusedRowHandle Property
Get or sets the focused row’s handle.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
Declaration
Property Value
Type | Description |
---|---|
Int32 | An integer value that is the handle of the focused record. |
Remarks
The following code focuses the second data row in the view:
The following code focuses the first group row in the view:
Tip
The following help topic describes row index types: Tutorial - Identifying Rows.
When row focus changes, ColumnView.FocusedRowChanged and ColumnView.FocusedRowObjectChanged events are raised.
See the following help topic for more information on row focus: Moving Row Focus.
Use the FocusedRowHandle
property only when the Data Grid is completely initialized (for example, you can handle the form’s Shown
event). To specify the focused row when the form loads, call the GridControl.ForceInitialize method to ensure that the grid control is initialized.
The following code sets the FocusedRowHandle
property in the form’s Load event handler:
void Form1_Load(object sender, EventArgs e) {
gridControl1.ForceInitialize();
gridView1.FocusedRowHandle = 2;
}
If no row is focused, the FocusedRowHandle
property returns the GridControl.InvalidRowHandle value. For instance, this value is returned when the View is empty. You can use the ColumnView.FocusInvalidRow method to temporarily hide row focus.
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 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.
Component-Specific Remarks
In Layout and Card Views, when you change the FocusedRowHandle
property value, the ColumnView.FocusedColumn property resets to null. Manually edit the FocusedColumn
property to move focus to a specific card field.
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.