# Formatting Data Rows

Use the **RowFormatting** event to apply custom formatting to RadVirtualGrid's data rows. The code snippet below demonstrates changing the **ForeColor**, **BackColor** and **GradientStyle** in all data rows where the cell value in the *ContactTitle* column is *Owner*:

![WinForms RadVirtualGrid Formatting Data Rows](https://www.telerik.com/products/winforms/documentation/assets/cf92603e9edd9d3e2a046f002a18c3b6/virtualgrid-cells-formatting-data-rows001.png)

```C#
private void radVirtualGrid1_RowFormatting(object sender, VirtualGridRowElementEventArgs e)
{ 
    VirtualGridCellElement contactTitleCell = radVirtualGrid1.VirtualGridElement.GetCellElement(e.RowElement.RowIndex, 3, radVirtualGrid1.MasterViewInfo);
    if (contactTitleCell != null && contactTitleCell.Value != null && contactTitleCell.Value.ToString() == "Owner")
    {
        e.RowElement.DrawFill = true;
        e.RowElement.BackColor = Color.Yellow;
        e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        e.RowElement.ForeColor = Color.Red;
    }
    else
    {
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
    }
}

```

```VB.NET
Private Sub radVirtualGrid1_RowFormatting(sender As Object, e As VirtualGridRowElementEventArgs)
    Dim contactTitleCell As VirtualGridCellElement = RadVirtualGrid1.VirtualGridElement.GetCellElement(e.RowElement.RowIndex, 3, RadVirtualGrid1.MasterViewInfo)
    If contactTitleCell IsNot Nothing AndAlso contactTitleCell.Value IsNot Nothing AndAlso contactTitleCell.Value.ToString() = "Owner" Then
        e.RowElement.DrawFill = True
        e.RowElement.BackColor = Color.Yellow
        e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
        e.RowElement.ForeColor = Color.Red
    Else
        e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
        e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    End If
End Sub

```

> caution Due to the UI virtualization in **RadVirtualGrid**, row elements are created only for currently visible rows and are being reused during operations like scrolling, filtering, sorting and so on. In order to prevent applying the formatting to other columns' row elements (because of the row reuse) all customization should be reset for the rest of the row elements.

## See Also

* [Alternating Row Color](https://www.telerik.com/products/winforms/documentation/controls/virtualgrid/visual-elements/rows/alternating-row-colors)

* [Formatting System Rows](https://www.telerik.com/products/winforms/documentation/controls/virtualgrid/visual-elements/rows/formatting-system-rows)

* [Pinned Rows](https://www.telerik.com/products/winforms/documentation/controls/virtualgrid/visual-elements/rows/pinned-rows)

* [Resizing Rows Programmatically](https://www.telerik.com/products/winforms/documentation/controls/virtualgrid/visual-elements/rows/resizing-rows-programmatically)

* [System Rows](https://www.telerik.com/products/winforms/documentation/controls/virtualgrid/visual-elements/rows/system-rows)
