Articles in this section
Category / Section

How to resize the column widths or row heights to entire text in a cell is visible in WinForms GridControl?

1 min read

Resizing the column width and row height

To resize the columns for the text to be visible, you can use the grid.Model.ColWidths.ResizeToFit method. This method takes two arguments, the GridRangeInfo object that specifies the cells to be resized and the GridResizeToFitOptions setting that specifies certain behaviors. The last setting controls whether to allow the shrinking of the cell when it is resized and whether to include any header cell in the resizing.

To resize the row heights, you can use the grid.Model.RowHeights.ResizeToFit method.


//Sets the ResizeToFit for rows 1 to 5.
this.gridControl1.Model.RowHeights.ResizeToFit(GridRangeInfo.Rows(1,5), GridResizeToFitOptions.NoShrinkSize);
//Sets the ResizeToFit for Column 2.
this.gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Col(2), GridResizeToFitOptions.NoShrinkSize);


'Sets the ResizeToFit for rows 1 to 5.
Me.gridControl1.Model.RowHeights.ResizeToFit(GridRangeInfo.Rows(1,5), GridResizeToFitOptions.NoShrinkSize)
'Sets the ResizeToFit for Column 2.
Me.gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Col(2), GridResizeToFitOptions.NoShrinkSize)

Resizing the entire grid with large grids can be time consuming. To resize only the visible areas of the grid, you can set the range argument to the grid.ViewLayout.VisibleCellsRange.


In the following image, the ResizeToFit is applied to the second column and 1 to 5 rows.

Resizing the rows and column width in WinForms Gridcontrol


C#: Resize-C#

VB: Resize-VB

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Please sign in to leave a comment