# Formatting Rows

## Customize the appearance of data rows

Use the **RowFormatting** event to apply custom formatting to **RadGridView's** data rows.

The code snippet below demonstrates changing the background color of rows, which *"BMP"* cell value is set to *true*:

![WinForms RadGridView Formatted Rows](https://www.telerik.com/products/winforms/documentation/assets/14e93450ff661fff53389c463cb57225/grid-rows-formatting-rows001.png)

```C#

private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
    if ((bool)e.RowElement.RowInfo.Cells["BMP"].Value == true)
    {
        e.RowElement.DrawFill = true;
        e.RowElement.GradientStyle = GradientStyles.Solid;
        e.RowElement.BackColor = Color.Aqua;
    }
    else
    {
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
    }
}

```

```VB.NET
Private Sub RadGridView1_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles RadGridView1.RowFormatting
    If e.RowElement.RowInfo.Cells("BMP").Value = True Then
        e.RowElement.DrawFill = True
        e.RowElement.GradientStyle = GradientStyles.Solid
        e.RowElement.BackColor = Color.Aqua
    Else
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
    End If
End Sub
```

> note An *if-else* statement is used to reset the value of **BackColorProperty** if no drawing is required.

> note You should set **DrawFill** to *true* to turn on the fill for the row (depends on the used theme).

> note Please refer to the Fundamentals [topic](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/logical-vs.-visual-grid-structure) for more information about the UI Virtualization.

## Customize the Non-Data Rows Appearance

To customize the non-data rows (header row, new row, filtering row, etc) of **RadGridView**, you need to handle the **ViewRowFormatting** event.

```C#
void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
{
    
    if (e.RowElement is GridTableHeaderRowElement)
    {
        e.RowElement.DrawFill = true;
        e.RowElement.BackColor = Color.Navy;
        e.RowElement.NumberOfColors = 1;
        e.RowElement.ForeColor = Color.White;
    }
    else
    {
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
    }
}
```

```VB.NET
Private Sub RadGridView1_ViewRowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles RadGridView1.ViewRowFormatting
    If TypeOf e.RowElement Is GridTableHeaderRowElement Then
        e.RowElement.DrawFill = True
        e.RowElement.BackColor = Color.Navy
        e.RowElement.NumberOfColors = 1
        e.RowElement.ForeColor = Color.White
    Else
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    End If
End Sub
```

![WinForms RadGridView Customized Non-Data Rows](https://www.telerik.com/products/winforms/documentation/assets/12bab989a8ee73420df6296a58989d5f/grid-rows-formatting-rows002.png)

## See Also

* [Adding and Inserting Rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/adding-and-inserting-rows)

* [Conditional Formatting Rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/conditional-formatting-rows)

* [Creating custom rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/creating-custom-rows)

* [Drag and Drop](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/drag-and-drop)

* [GridViewRowInfo](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/gridviewrowinfo)

* [Iterating Rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/iterating-rows)

* [New Row](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/new-row)

* [Painting Rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/visual-elements/rows/painting-rows)

* [Change the row hot tracking color in RadGridView by using VSB](https://www.telerik.com/products/winforms/documentation/knowledge-base/change-row-hot-tracking-color-in-vsb)
