This is a migrated thread and some comments may be shown as answers.

Wrong resizing of RadGridView

2 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rocio
Top achievements
Rank 1
Rocio asked on 08 Aug 2012, 08:12 AM
Hello, I am new with Telerik controls, but it's making my applications looks much better.
But I have a problem, My application has a RadTabControl with 4 RadTabItem, and the RadTabItems contains a grid with a RadGridView with an ItemsSource, this is the one that is wrong:

<telerik:RadTabItem Name="StatusTab" Header="Status Summary" IsSelected="True" MouseUp="StatusTab_MouseUp">
                <Grid>
                    <telerik:RadGridView Margin="47.773,61.105,0,0" Name="gridStatus" AutoGenerateColumns="False" ColumnWidth="Auto" telerik:StyleManager.Theme="Vista" CanUserDeleteRows="False" CanUserInsertRows="False" ActionOnLostFocus="None" Height="Auto" VerticalAlignment="Top" Width="Auto" HorizontalAlignment="Left">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Key}" Width="auto"/>
                            <telerik:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Value.Description}"  Width="auto" />
                            <telerik:GridViewDataColumn Header="State" DataMemberBinding="{Binding Value.State}"  Width="auto"/>
                         </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </Grid>
            </telerik:RadTabItem>

I have ser my RadGridView "gridStatus" Height, Width and ColumnWidth to Auto, but in runtime I get an extra column and the content does not fit the width of the RadGridView ( I attach a screen print)

I have tried to set Height and Width in Page1.xaml.cs but I canĀ“t set it to Auto, because the value has to be a double.

But the weirdest thing is that I have another RadGridView that works fine, I copied the code from this to the other, and removed a column that I didn't need, and it was the same, the properties are set to Auto, but I have an "extra column".

Hope you can help me because I have no idea of what to to.
Thanks!

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 08 Aug 2012, 08:50 AM
Hi,

Column width "auto" means the column will fit to the content of the cells. In your case you need to set  a "star" size for the column.
e.g. Width="*"  or width = "2*" .


All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rocio
Top achievements
Rank 1
answered on 08 Aug 2012, 09:12 AM
Hello Pavel, thanks for your response, but I don't really understand it, I get the ColumnWidth is not what I need to change, I have to change the Width property of the RadGridView, haven't I?
I tried:
<telerik:RadGridView Margin="47.773,61.105,0,0" Name="gridStatus" AutoGenerateColumns="False" telerik:StyleManager.Theme="Vista" CanUserDeleteRows="False" CanUserInsertRows="False" ActionOnLostFocus="None" Height="Auto" VerticalAlignment="Top" Width="*" HorizontalAlignment="Left">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Key}" Width="auto"/>
                            <telerik:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Value.Description}"  Width="auto" />
                            <telerik:GridViewDataColumn Header="State" DataMemberBinding="{Binding Value.State}"  Width="auto"/>
                         </telerik:RadGridView.Columns>
                    </telerik:RadGridView>

but when I write Width="*" I get an error: "* string cannot be converted to Lenght".
Where do I have to put the *, and what does the 2* means?
I am sure that my problem is not really important, but it's my first time with telerik controls.
Thanks a lot.
Tags
GridView
Asked by
Rocio
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Rocio
Top achievements
Rank 1
Share this question
or