Skip to main content

GridViewAppearances.FocusedRow Property

Gets the appearance settings used to paint the currently focused row when the grid control contains focus. For the FocusedRow property to be in effect regardless of the grid control’s focused state, disable the GridOptionsSelection.EnableAppearanceHideSelection (view.OptionsSelection.EnableAppearanceHideSelection) option.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public AppearanceObject FocusedRow { get; }

Property Value

Type Description
AppearanceObject

A AppearanceObject object that provides the appearance settings used to paint the currently focused row.

Remarks

The current paint theme (skin) specifies the default appearance settings for grid elements. You can use the FocusedRow property and other properties available from the GridView.Appearance object to override the default appearance settings.

Apply custom appearance settings to the focused row

To customize the focused row’s appearance settings, use the following properties:

gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(100,180,80); //Applied when the grid is focused
gridView1.Appearance.FocusedRow.ForeColor = Color.LightYellow;

gridView1.Appearance.HideSelectionRow.BackColor = Color.DarkSeaGreen; //Applied when the grid is not focused

gridview-focusedrowappearance.gif

If you disable the GridOptionsSelection.EnableAppearanceHideSelection (view.OptionsSelection.EnableAppearanceHideSelection) option, the focused row is painted the same in the grid control’s focused and unfocused state. Use the FocusedRow property to apply custom appearance settings. The GridViewAppearances.HideSelectionRow property is ignored.

Note

In multiple row selection mode (ColumnViewOptionsSelection.MultiSelect), the appearance settings specified by the FocusedRow property are only in effect when a row is focused and selected at the same time. To customize the appearance of focused rows when they are not selected, handle the GridView.RowStyle or GridView.RowCellStyle event.

Paint the focused cell and other cells in the focused row in the same manner

By default, the focused cell’s appearance (GridViewAppearances.FocusedCell) is different from the appearance of other cells in the focused row.

focusedrow-focusedcell-default

To paint all cells in the focused row using the same appearance settings, disable the GridOptionsSelection.EnableAppearanceFocusedCell option.

// Make the grid read-only.
gridView1.OptionsBehavior.Editable = false;
// Prevent the focused cell from being highlighted.
gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
// Draw a dotted focus rectangle around the entire row.
gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;

Grid_HighlightEntireFocusedRow

Do not paint (highlight) the focused row

Set the GridOptionsSelection.EnableAppearanceFocusedRow property to false to disable the default and custom colors for the focused row.

gridView1.OptionsSelection.EnableAppearanceFocusedRow = false;

focusedrow-disableappearance.png

In this case, the focused row’s appearance matches the appearance of non-focused rows (GridViewAppearances.Row, GridViewAppearances.EvenRow and GridViewAppearances.OddRow).

You can still highlight the focused cell in this mode with the GridViewAppearances.FocusedCell property.

gridView1.OptionsSelection.EnableAppearanceFocusedRow = false;
gridView1.Appearance.FocusedCell.BackColor = Color.FromArgb(200,200,250);
gridView1.Appearance.FocusedCell.ForeColor = Color.DarkMagenta;

focusedrow-disableappearance-hightlighfocusedcell

For more information on appearances, see the Appearance and Conditional Formatting topic.

See Also