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

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 focused data row and focused group row’s appearance.

Note

  • A user can select several records simultaneously but they 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 Cell Merging topic for more information.

Member Table

Member Table: Focused Row

Example

This example shows how to focus a row which isn’t displayed within the current page. To do this, switch to the page which 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 which 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;
}