Skip to main content

How to: Dynamically Control the Height of Individual Rows

The following code demonstrates a GridView.CalcRowHeight event handler.

This event is used to specify heights of individual rows. It is assumed that a View (gridView1) displays data from the DataView data source, which contains the RowHeight column. This column specifies the height to set for a specific row.

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_CalcRowHeight(object sender, RowHeightEventArgs e) {
    GridView view = sender as GridView;
    if (view == null) return;
    if(e.RowHandle >= 0)
        e.RowHeight = (int)view.GetDataRow(e.RowHandle)["RowHeight"];