# Resizing Rows Programmatically

**RadVirtualGrid** exposes an API allowing resizing of its rows. In order to utilize it we need to set the **AllowRowResize** property to *true*.

```C#
this.radVirtualGrid1.AllowRowResize = true;
```

```VB.NET
Me.RadVirtualGrid1.AllowRowResize = True
```

## Resizing System Rows

The **VirtualGridViewInfo** object exposes properties for directly accessing its system rows and setting a desired height.

> caption Figure 1 Resizing System Rows.

![WinForms RadVirtualGrid Resizing System Rows](https://www.telerik.com/products/winforms/documentation/assets/29265b24d59874651442c3c3d5200efd/virtualgrid-rows-resizing-rows002.png)

```C#
this.radVirtualGrid1.MasterViewInfo.HeaderRowHeight = 30;
this.radVirtualGrid1.MasterViewInfo.NewRowHeight = 40;
this.radVirtualGrid1.MasterViewInfo.FilterRowHeight = 50;
```

```VB.NET
Me.RadVirtualGrid1.MasterViewInfo.HeaderRowHeight = 30
Me.RadVirtualGrid1.MasterViewInfo.NewRowHeight = 40
Me.RadVirtualGrid1.MasterViewInfo.FilterRowHeight = 50
```

## Resizing Data Rows

The data rows can also be programmatically resized. **RadVirtualGrid.VirtualGridViewInfo** provides a property for defining a uniform height to all rows and also methods for setting or retrieving the height of a single row.

> caption Figure 2 Resizing All Data Rows.

![WinForms RadVirtualGrid Resizing All Data Rows](https://www.telerik.com/products/winforms/documentation/assets/84f4e0238d0e04053d5e46de10f8953b/virtualgrid-rows-resizing-rows003.png)

```C#
this.radVirtualGrid1.MasterViewInfo.RowHeight = 60;
```

```VB.NET
Me.RadVirtualGrid1.MasterViewInfo.RowHeight = 60
```

> caption Figure 3 Resizing A Single Data Row.

![WinForms RadVirtualGrid Resizing A Single Data Row](https://www.telerik.com/products/winforms/documentation/assets/d84783c896b4ee44131ef3e82f0628aa/virtualgrid-rows-resizing-rows004.png)

```C#
this.radVirtualGrid1.MasterViewInfo.SetRowHeight(0, 40);
int rowHeight = this.radVirtualGrid1.MasterViewInfo.GetRowHeight(0);
```

```VB.NET
Me.RadVirtualGrid1.MasterViewInfo.SetRowHeight(0, 40)
Dim rowHeight As Integer = Me.RadVirtualGrid1.MasterViewInfo.GetRowHeight(0)
```

## Events

The API exposes two events for notifications when a change in the height of a row is about to happen or has already happened.

* **RowHeightChanging**: Raised before the operation starts, it can be canceled. The event arguments are:

  * **Cancel**: If set to *true* suspends the operation.

  * **NewHeight**: Value of the new row height.

  * **OldHeight**: Value of the old row height.

  * **RowIndex**: The index of the row which is about to be resized.

  * **ViewInfo**: Reference to the **VirtualGridViewInfo** object.

* **RowHeightChanged**: Raised after the execution of the resizing operation. The event arguments are:

  * **RowIndex**: The index of the resized row.

  * **ViewInfo**: Reference to the **VirtualGridViewInfo** object.

```C#
private void radVirtualGrid1_RowHeightChanging(object sender, VirtualGridRowHeightChangingEventArgs e)
{
    if (e.RowIndex == 0)
    {
        e.Cancel = true;
    }
}

private void radVirtualGrid1_RowHeightChanged(object sender, VirtualGridRowEventArgs e)
{

}
```

```VB.NET
Private Sub radVirtualGrid1_RowHeightChanging(sender As Object, e As VirtualGridRowHeightChangingEventArgs)
    If e.RowIndex = 0 Then
        e.Cancel = True
    End If
End Sub

Private Sub radVirtualGrid1_RowHeightChanged(sender As Object, e As VirtualGridRowEventArgs)

End Sub
```

## See Also

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

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

* [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)

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