Skip to main content
A newer version of this page is available. .

ColumnView.FocusedRowHandle Property

Gets or sets the focused record by its handle.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v17.2.dll

Declaration

[Browsable(false)]
public int FocusedRowHandle { get; set; }

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 identifies the currently focused record within the View or the record to move focus to.

To focus a specific record, assign the corresponding handle to the FocusedRowHandle property. This will also make the specified record visible on screen (the View will be scrolled and group rows expanded if required). Setting the FocusedRowHandle property to a handle that doesn’t correspond to any record within the View has no effect.

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. If the View contains records, an assignment of the GridControl.InvalidRowHandle value to the FocusedRowHandle property has no effect.

Note that the FocusedRowHandle property doesn’t determine whether the Grid control is focused. When the Grid loses focus, row focus is never lost.

When row focus changes, the ColumnView.FocusedRowChanged and ColumnView.FocusedRowObjectChanged events are raised. See the ColumnView.FocusedRowObjectChanged topic to learn about the difference between these events.

After moving focus between cards in LayoutViews and CardViews via the FocusedRowHandle inherited property, the ColumnView.FocusedColumn property is automatically set to null. In this instance, you may want to manually move focus to a specific card field via the FocusedColumn property after changing the FocusedRowHandle.

Multiple Row/Card Selection Mode

The focused row/card is the row that accepts input from an end-user. There can only be one focused row in a View, regardless of selection mode. Compared to row focusing, row selection is only a visual feature designated for highlighting certain rows.

In multiple row/card selection mode, when an end-user focuses a new row with either the Arrow keyboard keys or using the mouse, then that row is selected (highlighted). When you focus a certain row in code (e.g., with the ColumnView.FocusedRowHandle property), this row is not automatically selected (highlighted). You can select/deselect the focused row in code when required. An end-user can also toggle the selected state for the focused row using the mouse and keyboard, as shown in the End-User Capabilities - Select Grid Rows and Cards topic.

The following images demonstrate the selected and deselected states for a focused row.

Focused Row is selected

MultiSelect-FocusedRowSelected

The ColumnView.GetSelectedRows method will return three row handles, including the focused row handle.

Focused Row is deselected

MultiSelect-FocusedRowDeSelected.png

The ColumnView.GetSelectedRows method will return two handles that correspond to selected rows. The focused row handle will not be included in the method’s resulting array.

See the Multiple Row and Cell Selection topic to learn how to select rows in code.

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.

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.

See Also