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

How to set the width of Last column

6 Answers 557 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 15 Sep 2014, 07:17 PM
I am setting the width of all the columns in the grid to Auto: column.Width = GridViewLength.Auto;
But the last column does not cover the entire area (attached image).


I also have changed the style of telerik:GridViewHeaderCell, and because the last column do not stretch i can see another cell with a different back ground color.
How can i change the color of that column header

Thanks
Vikas

6 Answers, 1 is accepted

Sort by
0
Accepted
Boris
Telerik team
answered on 16 Sep 2014, 12:49 PM
Hello Vikas,

In order to cover the entire area after the last column as a part of it, you can set it's Width property to "*" in XAML or in code-behind, by Initializing a new instance of the GridViewLength structure, with the following GridViewLength(Double, GridViewLengthUnitType) constructor.

this.clubsGrid.Columns["ColumnUniqueName"].Width = new GridViewLength(100.123,GridViewLengthUnitType.Star);

I hope this helps.

Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Vikas
Top achievements
Rank 1
answered on 09 Oct 2014, 05:55 PM
After setting the width to GridViewLength(100.123,GridViewLengthUnitType.Star); I still see an extra column at the end with a black header background.

and i have to set the width in the source updated event, If i set the width after adding the column to the width The horizontal scrollabr does not show up
0
Boris
Telerik team
answered on 14 Oct 2014, 11:38 AM
Hi Vikas,

I attached a sample project that demonstrates the suggested approach from my previous reply.

Please examine it an let us know how it goes.

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Vikas
Top achievements
Rank 1
answered on 14 Oct 2014, 06:57 PM
I was able to use your solution and the last column does stretch, but then the horizontal scroll bar does not appear.
I am creating the columns in the code behind because the Grid can have different columns

AddColumn("Description", 300, "GridDescription");
AddColumn("Claim Format", 100, "ColumnValue3", true, true);

and for the last column i set its width to Star (according to your solution), the data however is coming from ItemSource.

Vikas
0
Boris
Telerik team
answered on 15 Oct 2014, 10:13 AM
Hi Vikas,

In general setting the Width property of any column to "*" means that this column will get the extra space and it will try to fit into the viable area. 

As for the horizontal ScrollBar, it will appear only when the viewable area is too small to display all the columns. 

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Vikas
Top achievements
Rank 1
answered on 17 Oct 2014, 06:51 PM
Thanks, I will try that.
vikas
Tags
GridView
Asked by
Vikas
Top achievements
Rank 1
Answers by
Boris
Telerik team
Vikas
Top achievements
Rank 1
Share this question
or