Controlling Columns Width
The GridViewColumn elements can be manually sized by setting their width.
The column width can be set on the GridViewColumn elements via the Width property or on the RadGridView control via the ColumnWidth property. Both are of type ColumnWidth.
There are several values that you can assign to the property:
-
SizeToCells—The width is set according to the longest text from the cells. -
SizeToHeader—The width is set according to the length of the column's header. This is the default sizing behavior. -
Auto—The width is set according to the longest value(might be the header or a value within the cell). -
*(star)—The column would take as much space as there is available. -
Fixed Width—You can set a fixed width for all the columns.
Setting the Width of All Columns with the ColumnWidth Property
Setting the RadGridView's ColumnWidth property affects all columns' size which don't have their Width set explicitly. The Width property of the column has higher priority than the ColumnWidth of RadGridView.
Example 1: Setting RadGridView's ColumnWidth
<telerik:RadGridView ItemsSource="{Binding Clubs}" ColumnWidth="*">
Example 2: Setting RadGridView's ColumnWidth in code
this.clubsGrid.ColumnWidth = new Telerik.Windows.Controls.GridViewLength(1, Telerik.Windows.Controls.GridViewLengthUnitType.Star);Setting the Width of a Column
Apart from setting the width for all the columns within the RadGridView, you can set the width for each individual column through its Width property.
Example 3: Setting the width of a specific column
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="Auto" />
Setting the width of a specific column in code
this.clubsGrid.Columns[0].Width = Telerik.Windows.Controls.GridViewLength.Auto; Setting Column MinWidth and MaxWidth
The minimum and maximum widths of the column headers can be adjusted using the MinWidth and MaxWidth properties of the GridViewColumn.
Also, these can be adjusted via the MinColumnWidth and MaxColumnWidth properties of RadGridView.
Using a
0value for theMinWidthandMinColumnWidthproperties is not supported. If you use a fixed size, use at least1.