How to set the width of Last column

7 posts, 1 answers
  1. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 15 Sep 2014 Link to this post

    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

  2. Answer
    Boris
    Admin
    Boris avatar
    276 posts

    Posted 16 Sep 2014 Link to this post

    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.
     
  3. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 09 Oct 2014 in reply to Boris Link to this post

    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
  4. Boris
    Admin
    Boris avatar
    276 posts

    Posted 14 Oct 2014 Link to this post

    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.

     
  5. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 14 Oct 2014 in reply to Boris Link to this post

    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
  6. Boris
    Admin
    Boris avatar
    276 posts

    Posted 15 Oct 2014 Link to this post

    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.

     
  7. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 17 Oct 2014 in reply to Boris Link to this post

    Thanks, I will try that.
    vikas
Back to Top