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

[Solved] How can I get columns to expand

3 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jerry Kurata
Top achievements
Rank 1
Jerry Kurata asked on 24 Aug 2010, 01:15 AM
Hi,

When my grid is initially created it only has a few columns.  We want the width of the grid to be fixed.  However, the minimum size for these columns is rather small to there is quite a bit of white space on the right edge of the grid.  This white space looks like an unlabeled column on the right edge.  I would like to have the right most column expand to fill this space. How can I accomplish this? 

I tried width auto and it had no effect.

3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 24 Aug 2010, 02:19 AM
Hi Jerry Kurata,

 You need to set the width of the last column to '*', that way it will take up all the remaining space.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerry Kurata
Top achievements
Rank 1
answered on 24 Aug 2010, 04:38 AM
Yavor,

This seems to do just the opposite.  It shrinks the width of the column leaving in more white space.

Here is the XAML

               <telerik:RadGridView Name="gridTest" Height="190" MinWidth="500">
                </telerik:RadGridView>
                <Button Content="Adjust Grid" Name="btnAdjGrid" Click="btnAdjGrid_Click" />


Here is the code that creates the data for the grid:

 People = new List<Person>();
            People.Add(new Person()
                {
                    Name = "jerry",
                    Address = "123 Main street",
                    Note = "Note 1"
                });

            People.Add(new Person()
            {
                Name = "Deb",
                Address = "3345 Oak Lant",
                Note = "Note 2"
            });

            this.gridTest.ItemsSource = People;

When the button is pressed this code executes:

this.gridTest.Columns[2].Width = '*';

0
Accepted
Yavor Georgiev
Telerik team
answered on 24 Aug 2010, 10:00 AM
Hi Jerry Kurata,

 In code-behind you need to do it like this:

this.radGridView1.Columns[1].Width = new GridViewLength(1, GridViewLengthUnitType.Star);

Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jerry Kurata
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Jerry Kurata
Top achievements
Rank 1
Share this question
or