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

GridView.RowStyle Event

Enables the appearance settings of individual rows to be changed.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v17.2.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

The RowStyle event is raised for individual data or group rows before they are repainted. The appearance settings of the data and group rows are specified by the GridViewAppearances.Row and GridViewAppearances.GroupRow properties, respectively. Handle this event to override the appearance settings of individual rows.

The processed row can be identified using the event parameter’s RowEventArgs.RowHandle property. Its appearance settings are returned by the RowCellStyleEventArgs.Appearance property.

Setting an image to the Appearance.Image property has no effect when custom painting via the RowStyle and GridView.RowCellStyle events.

The appearance of selected rows cannot be customized via the RowStyle event. Use the GridView.CustomDrawCell event instead.

Note

The control’s events designed to change the appearance or rendering of control elements must not be used to update cell values or to modify the control’s layout. Any inappropriate operation which causes a layout update, may break the normal control behavior.

Note

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

Example

In the following example the GridView.RowStyle event is handled to customize the appearance of rows which have the value “Beverages” in the Category column. These rows are painted using gradient filling. The starting and ending gradient colors are specified via the AppearanceObject.BackColor and AppearanceObject.BackColor2 properties of the event’s RowStyleEventArgs.Appearance parameter.

The result is displayed below. Note that the gradients are applied to the entire rows and not to individual cells:

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;
      }            
   }
}

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