The event handler receives an argument of type RowStyleEventArgs containing data related to this event.
The following
RowStyleEventArgs properties provide information specific to this event.
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 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](xref:711) handle the GridView.CustomDrawCell (see 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 RowStyle event to highlight rows that have "Beverages" under the Category column.

C# |
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;
}
}
}
|
VB |
Imports DevExpress.XtraGrid.Views.Grid
Private Sub GridView1_RowStyle(ByVal sender As Object, _
ByVal e As DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs) Handles GridView1.RowStyle
Dim View As GridView = sender
If (e.RowHandle >= 0) Then
Dim category As String = View.GetRowCellDisplayText(e.RowHandle, View.Columns("Category"))
If category = "Beverages" Then
e.Appearance.BackColor = Color.Salmon
e.Appearance.BackColor2 = Color.SeaShell
e.HighPriority = True
End If
End If
End Sub
|