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

GridView.RowCellStyle Event

Fires for every Grid cell before this cell is shown. Allows you to modify Appearance settings for this cell.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.1.dll


public event RowCellStyleEventHandler RowCellStyle

Event Data

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

Property Description
Appearance Gets the appearance settings used to paint the data cell currently being processed.
CellValue Returns the currently processed cell value. Inherited from CustomRowCellEventArgs.
Column Gets the column to which the currently processed cell corresponds. Inherited from CustomRowCellEventArgs.
RowHandle Gets the handle of the row that contains the processed cell. Inherited from CustomRowCellEventArgs.

The event data class exposes the following methods:

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


Use the event’s CustomRowCellEventArgs.RowHandle and CustomRowCellEventArgs.Column parameters to identify the currently processed cell, then change the RowCellStyleEventArgs.Appearance parameter to modify Appearance settings.

The Appearance of column cells sample in the DevExpress Demo Center illustrates how to apply different colors and text alignment settings to the “Name” column cells depending on whether the checkbox under the “Mark” column is checked.

    gridView.RowCellStyle += (sender, e) => {
        GridView view = sender as GridView;
        bool _mark = (bool)view.GetRowCellValue(e.RowHandle, "Mark");
        if(e.Column.FieldName == "Name") {
            e.Appearance.BackColor = _mark ? Color.LightGreen : Color.LightSalmon;
            e.Appearance.TextOptions.HAlignment = _mark ? HorzAlignment.Far : HorzAlignment.Near;
        if(e.Column.FieldName == "Length") {
            double _length = (double)e.CellValue;
            if(_length > 25)
                e.Appearance.ForeColor = Color.Red;

To provide appearance settings for entire rows instead of individual cells, handle the GridView.RowStyle event.


Data Grid does not display cell images assigned to the Appearance.Image properties on the RowCellStyle and GridView.RowStyle events. See the “Cell Icons” section of the Cells article to learn how to provide icons for Grid cells.


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.

Please refer to the Appearance and Conditional Formatting topic for additional information.

Online Video

WinForms Grid: Custom Drawing.


The following code demonstrates how to customize the appearance of individual grid cells using the GridView.RowCellStyle event handler. The grid cells in this example are colored in a staggered manner. The following image demonstrates the result:


using DevExpress.XtraGrid.Views.Grid;

private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e) {
   GridView view = sender as GridView;
   if(view == null) return;
   if(e.RowHandle != view.FocusedRowHandle && 
      ((e.RowHandle % 2 == 0 && e.Column.VisibleIndex % 2 == 1) || 
      (e.Column.VisibleIndex % 2 == 0 && e.RowHandle % 2 == 1)))    
      e.Appearance.BackColor = Color.NavajoWhite;

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


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