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

GridView.RowStyle Event

Allows you to override the GridViewAppearances.Row and GridViewAppearances.GroupRow appearance settings for any data or group row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.1.dll

Declaration

[DXCategory("Appearance")]
public event RowStyleEventHandler RowStyle

Event Data

The RowStyle event's data class is RowStyleEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the appearance settings used to paint the cells within the row currently being processed.
HighPriority Gets or sets whether the appearance settings provided by the GridView.RowStyle event have a higher priority than the appearances specified by the GridViewAppearances.EvenRow and GridViewAppearances.OddRow properties.
RowHandle Gets the row’s handle (position). For the ColumnView.RowUpdated event, this property specifies the previous handle (position) of the currently processed row. Inherited from RowEventArgs.
State Gets the current state of the processed row.

The event data class exposes the following methods:

Method Description
CombineAppearance(AppearanceObject) Copies the activated settings of the appearance object passed as the parameter.

Remarks

To identify the currently processed row, read RowEventArgs.RowHandle property value. The RowCellStyleEventArgs.Appearance property returns this row’s default appearance.

If you handle the GridView.RowCellStyle event to custom draw cells, an image assigned to the Appearance.Image property in the RowStyle event handler is ignored.

To change appearance settings of selected rows handle the GridView.CustomDrawCell event instead.

Important

Never change cell values or modify the control’s layout on this event, or any other event designed to tune the control’s appearance. Any action that causes a layout update can cause the control to malfunction.

Note

The appearance settings provided via the RowStyle event are not in effect when the grid control is printed and exported.

Example

The sample below handles the GridView.RowStyle event to highlight rows that have “Beverages” under the Category column.

CD_Appearance_Cells_RowStyle_example

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_RowStyle(object sender, 
DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) {
   GridView View = sender as GridView;
   if(e.RowHandle >= 0) {
      string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["Category"]);
      if(category == "Beverages") {
         e.Appearance.BackColor = Color.Salmon;
         e.Appearance.BackColor2 = Color.SeaShell;
         e.HighPriority = true;
      }            
   }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the RowStyle event.

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