Focused Row Overview

  • 2 minutes to read

A focused row is a clicked ASPxGridView record. Set the ASPxGridViewBehaviorSettings.AllowFocusedRow property to true to enable the Focused Row feature.

The GridViewStyles.FocusedRow and GridViewStyles.FocusedGroupRow properties allow you to access and customize the appearance of the focused data row and focused group row.

Note

  • A user can select multiple records simultaneously, but can focus only one record at a time.
  • If you focus a row and navigate to another page, the row loses focus. However, if you select a row or several rows (in multi-select mode) and then navigate to another page, the grid saves this selection.
  • You cannot focus a row when the ASPxGridViewBehaviorSettings.AllowCellMerge property is set to true. Refer to the following topic for more information: Cell Merging.

Member Table

Member Table: Focused Row

Example

This example shows how to focus a row that is not displayed within the current page. To do this, switch to the page that contains the required row, and then move row focus.

using DevExpress.Web.ASPxGridView;

...

protected void Button1_Click(object sender, EventArgs e) {
    // Obtain the visible index of the required row.
    int rowIndex = grid.FindVisibleIndexByKeyValue("OLDWO");
    if (rowIndex == ASPxGridView.InvalidRowIndex) return;
    if (!IsRowVisibleOnScreen(rowIndex)) {
        // Switch to the page that contains the required row.
        GoToPage(rowIndex);
    }
    // Focus the required row.
    grid.FocusedRowIndex = rowIndex;
}
bool IsRowVisibleOnScreen(int rowIndex) {
    int startIndex = grid.PageIndex * grid.SettingsPager.PageSize;
    int endIndex = startIndex + grid.SettingsPager.PageSize;
    return rowIndex >= startIndex && rowIndex < endIndex;
}
void GoToPage(int rowIndex) {
    grid.PageIndex = rowIndex / grid.SettingsPager.PageSize;
}