New to Telerik UI for WPF? Download free 30-day trial

Controlling Columns Width

There are a couple of approaches available for setting the width of the columns within RadGridView:

On RadGridView Level

You can set RadGridView's ColumnWidth property which will affect all columns' width (unless the width is set explicitly for the column).

Example 1: Setting RadGridView's ColumnWidth

    <telerik:RadGridView Name="clubsGrid"  
                         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); 
Me.clubsGrid.ColumnWidth = New Telerik.Windows.Controls.GridViewLength(1, Telerik.Windows.Controls.GridViewLengthUnitType.Star) 

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 value.

  • Auto: The width is set according to the longest value(might be the header or a value within the cell).

  • * (Star): The columns would take as much space as there is available.

  • Fixed Width: You can set a fixed width for all the columns.

On Column Level

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" />  

Example 4: Setting the width of a specific column in code

this.clubsGrid.Columns[0].Width = Telerik.Windows.Controls.GridViewLength.Auto;  
Me.clubsGrid.Columns(0).Width = Telerik.Windows.Controls.GridViewLength.Auto     

The values that could be assigned to the property are enumerated below:

  • 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.

  • Auto: The width is set according to the longest value(might be the header or a value within the cell). This is the default value.

  • * (Star): The column would take as much space as there is available.

  • Fixed Width: You can set a fixed width for each column.

See Also

In this article