Skip to main content
A newer version of this page is available. .


  • 7 minutes to read

Row Height

There are two types of rows in the Data Grid: data rows (that represent data source records) and non-data service rows (group rows, new item rows, etc.).

Data Grid - Row Heights

By default, row height is determined by font settings. The Data Grid provides the following API to modify these heights.

  • GridView.RowHeight

    Specifies the data row height in pixels. The default value is -1 and rows have no constant height.

  • GridView.ColumnPanelRowHeight

    Specifies the height of column headers.

  • GridView.GroupRowHeight

    Gets or sets the group rows’ height.

  • GridView.RowSeparatorHeight

    Specifies the vertical distance between rows. Setting this property to zero does not remove horizontal lines between rows. To do that, disable the GridOptionsView.ShowHorizontalLines setting.

  • GridView.CalcRowHeight

    This event repeatedly rises for every row and allows you to set individual height parameters for each of them. The code snippet below illustrates how to set row heights based on values from the “RowHeight” data source field.

    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"];

Auto Row Height

By default, row cells clip content that they cannot display entirely. To change this behavior, utilize the MemoEdit, TokenEdit or PictureEdit editors as in-place editors for required columns and enable the GridOptionsView.RowAutoHeight setting. This will allow Data Grid data rows to dynamically adapt to the content and gain different heights.

Data Grid - Auto Row Height

Demo: Auto Row Height

Hide Horizontal Row Borders

You can hide column and row borders by disabling the GridOptionsView.ShowVerticalLines and GridOptionsView.ShowHorizontalLines settings.

Data Grid - Horizontal Lines

Row Indicator Panel

A row indicator panel is a horizontal strip docked to the Data Grid’s left edge. End-users can click this bar to select any Data Grid row.

DataGrid - Row Indicator Panel

Row indicator panel displays various icons depending on what row is currently selected and which row operation is ongoing.

  • Indicator_FocusedRow - the focused row.
  • Indicator_RowInEditMode - a row cell is being edited by an end-user.
  • Indicator_ModifiedRow - the row has been modified.
  • Indicator_NewItemRow - the focused row is a new item row.
  • Indicator_AutoFilterRow - the focused row is an auto-filter row.
  • Indicator_MaximizeDetailView - end-users can click this icon to maximize a detail View.
  • Indicator_RestoreDetailView - end-users can click this icon to restore a detail View.
  • Indicator_NonFocusedRowContainsErrors - the row contains errors.
  • Indicator_FocusedRowContainsErrors - the focused row contains errors.

Related API

Row Multi-Select

If the ColumnViewOptionsSelection.MultiSelect option is enabled, end-users are able to select multiple rows using marquee selection, keyboard arrow keys and mouse clicks with the Ctrl/Shift keys pressed.

Data Grid - MultiSelect Animation

Related API

Web Style Row Selection

Along with clicking a row indicator panel, end-users can utilize check boxes to select data rows. To enable these check boxes, set the GridOptionsSelection.MultiSelectMode property to the GridMultiSelectMode.CheckBoxRowSelect value. Web style selection is available only when row multi-select is on.

Data Grid - Web Style Row Selection

Related API

Demo: Web Style Row Selection

Accessing Rows in Code. Row Handles

Every Data Grid row has three integer values that identify it: a data source index, a row handle and a visible index.

Data source indexes

  • Specify zero-based row indexes in the bound list.
  • Constant values that do not change when you sort, group or filter data.
  • For group rows, they will point to the first data row in the group.
  • Used for accessing data.

Row handles

  • Zero-based indexes that correspond to row order from top to bottom.
  • Group row handles are negative values that start with -1. The order matches the order of group rows from top to bottom.
  • The grid specifies reserved row handles for the New Item Row, Auto Filter Row and an Invalid Row.
  • Row handles are re-assigned to rows after each data operation.
  • When the View is filtered, rows and row handles are created only for rows that match the filter.

Visible indexes

  • Zero-based indexes that match the order of visible rows, from top to bottom.
  • Service rows get negative indexes if displayed above data and group rows.
  • Re-assigned after each data operation, including data sorting, grouping and filtering.
  • Visible indexes are only assigned to rows in expanded groups. Thus, the indexes are updated after each expand/collapse operation.

Grid - Group Row Handles

For master-detail data, all detail Views have their own unique visible indexes and row handles.

Related API

Traversing Rows

When you need to process all Data Grid rows one-by-one, use the following approach.

  • Read the BaseView.DataRowCount property value to determine the actual number of existing rows.
  • To alter all existing rows, implement a loop that goes over row handles starting from 0 to DataRowCount - 1.
  • If you need to process visible rows only, begin with a row that has a zero handle and then obtain the next rows by calling the ColumnView.GetNextVisibleRow method.
  • Wrap your loop inside the ColumnView.BeginSort/ColumnView.EndSort methods pair to prevent reloading data while processing rows is still in progress. Otherwise, changing cell values may change a row order (together with row handles), which will cause your row processing algorithm to malfunction.

The code sample below iterates through grid records and reduces the “Price” column values by 10 percent.

private void UpdatePrice(DevExpress.XtraGrid.Views.Base.ColumnView View) {
   // Obtain the Price column. 
   DevExpress.XtraGrid.Columns.GridColumn col = View.Columns.ColumnByFieldName("Price");
   if (col == null) return;
   try {
      // Obtain the number of data rows. 
      int dataRowCount = View.DataRowCount;
      // Traverse data rows and change the Price field values. 
      for (int i = 0; i < dataRowCount; i++) {
         object cellValue = View.GetRowCellValue(i, col);
         double newValue = Convert.ToDouble(cellValue) * 0.9;
         View.SetRowCellValue(i, col, newValue);
   } finally { View.EndSort(); }
See Also