Resizing columns
The columns inside the RadGridView are resizable by default. The user is able to easily change the column width by positioning the
mouse over the columns vertical grid line and dragging it until the desired size is achieved.
The width of columns can be set individually, per column. Note that the visible width will always include some amount of data even when set
to very small amounts. To resize the columns programmatically you can use the Width property. For example:
Copy[C#] Rezise a column programatically
this.radGridView1.Columns["Photo"].Width = 100;
Copy[VB.NET] Rezise a column programatically
Me.RadGridView1.Columns("Photo").Width = 100
You can restrict the possible values of the Width property by setting the MinWidth and
MaxWidth properties. The MinWidth property sets a limit on how narrow the column can be
resized. The MaxWidth property determines the limit on how the column width can grow.
Disabling resizing
There are two ways to disable the resizing of columns in the user interface:
-
To restrict the resizing of all columns by the user set the AllowColumnResize property of RadGridView
to false
Copy[C#] Disable resizing
this.radGridView1.AllowColumnResize = false;
Copy[VB.NET] Disable resizing
Me.RadGridView1.AllowColumnResize = False
-
To restrict the resizing of a particular column set the AllowResize property of the column
to false.
Copy[C#] Disable resizing for a specified column
this.radGridView1.Columns["Photo"].AllowResize = false;
Copy[VB.NET] Disable resizing for a specified column
Me.RadGridView1.Columns("Photo").AllowResize = False
Column Auto-Sizing
The RadGridView can calculate the width of the column automatically depending on the mode the column is in.
Auto-Size Column Mode
Here, columns can automatically fill the entire width of the grid. Just set the GridViewTemplate.AutoSizeColumnsMode
property to GridViewAutoSizeColumnsMode.Fill.
Best fit
The column widths can be set to fit the content by using the GridViewTemplate.BestFitColumns or
GridViewDataColumn.BestFit methods. This mode distributes algorithm that attempts to fit in the header text and
column data for all visible rows.
The user can perform the best fit:
-
By using the context menu of the header cell
-
By double clicking of the left or right header edge
You can customize the execution of the algorithm of a concrete column by setting its AutoSizeMode property.
There are the following options:
- BestFitColumnMode.None - The column width does not automatically adjust.
- BestFitColumnMode.DisplayedDataCells - The column width adjusts to fit the contents of the displayed data cells.
- BestFitColumnMode.HeaderCells - The column width adjusts to fit the contents of the header cell.
- BestFitColumnMode.FilterCells - The column width adjusts to fit the contents of the filter cell.
- BestFitColumnMode.SymmaryRowCells - The column width adjusts to fit the contents of the summary row cell.
- BestFitColumnMode.SystemCells - The column width adjusts to fit the contents of the system cells.
- BestFitColumnMode.DisplayedCells - The column width adjusts to fit the contents of the displayed cells.
Resizing events
When the user resizes the column the ColumnWidthChanging event is fired and if it is not canceled
the ColumnWidthChanged event fires after the resize is completed.