我有一个RadGrid,它没有任何固定的宽度或高度,其水平和垂直对齐设置为拉伸。它有5列,其中2列有固定宽度,其他列设置为auto。调整窗口大小时,虽然网格调整大小以填充可用空间,但列保留其宽度(自动)。我想知道如何增加单个列的宽度,以便在调整大小时占用网格内的整个空间。代码如下所示。感谢名单。
<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>
答案 0 :(得分:1)
这种方法对我很有用,把每列的初始宽度加上*并添加到应该可调整大小的列
Width="200*"
您的示例将如此
<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}"/>