Sangeetha
Sangeetha

Reputation: 515

Increase column widths as Grid resizes

i have a RadGrid, which doesnt have any fixed width or height, and whose horizontal and vertical alignment is set to stretch. it has 5 columns, out of which 2 columns have fixed widths and the others are set to auto. When the window is resized, though the grid gets resized to fill the available space, the columns retain their widths(auto). i would like to know how to increase the individual columns' widths so that it takes up the entire space within the grid when resized. The code is as given below. Thanx.

<telerik:RadGridView VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Title" HeaderTextAlignment="Center" DataMemberBinding="{Binding Title}"/>
            <telerik:GridViewDataColumn Header="Description" HeaderTextAlignment="Center" DataMemberBinding="{Binding Description}"/>
            <telerik:GridViewDataColumn Header="User" HeaderTextAlignment="Center" DataMemberBinding="{Binding User}"/>
            <telerik:GridViewDataColumn Width="110" Header="Date" HeaderTextAlignment="Center" DataMemberBinding="{Binding Date}"/>
            <telerik:GridViewDataColumn Width="110" Header="Time" HeaderTextAlignment="Center" DataMemberBinding="{Binding Time}"/>
  </telerik:RadGridView.Columns>
 </telerik:RadGridView>

Upvotes: 2

Views: 3317

Answers (1)

Mikhail
Mikhail

Reputation: 1028

This approach works for me fine, put initial widths of each column and add * to columns which should be resizable

Width="200*"

Your example will look like so

<telerik:RadGridView VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Width="150*" Header="Title" HeaderTextAlignment="Center" DataMemberBinding="{Binding Title}"/>
        <telerik:GridViewDataColumn Width="200*" Header="Description" HeaderTextAlignment="Center" DataMemberBinding="{Binding Description}"/>
        <telerik:GridViewDataColumn Width="100*" Header="User" HeaderTextAlignment="Center" DataMemberBinding="{Binding User}"/>
        <telerik:GridViewDataColumn Width="110" Header="Date" HeaderTextAlignment="Center" DataMemberBinding="{Binding Date}"/>
        <telerik:GridViewDataColumn Width="110" Header="Time" HeaderTextAlignment="Center" DataMemberBinding="{Binding Time}"/>

Upvotes: 1

Related Questions