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

How to set GridViewDataColumn width to Fill?

6 Answers 1097 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.
Tony
Top achievements
Rank 1
Tony asked on 08 Dec 2011, 04:33 AM
Hi,

I'm getting an extra column at the end of my grid when I resize the container. 

Reading the posts, I note that one way that I should be able to remove this extra column is by setting the width of the last column to fill (i.e. "*").

However, I am using an ObsevableCollection of GridViewDataColumns to generate the columns of my grid.

How do I set the width of the a GridViewDataColumn to fill.  Width takes a value of type GridViewLength which only have 3 options (i.e. Auto, SizeToCells, SizeToHeader) of which the default is Auto.

Thanks,

Tony

6 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 09 Dec 2011, 02:46 PM
Hello Tony,

 You could set the width to "*" like so:

column.Width = new GridViewLength(1, GridViewLengthUnitType.Star);

Please let me know if this is what you need. 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tony
Top achievements
Rank 1
answered on 13 Dec 2011, 11:38 PM
Thanks Didie - this worked like a charm.

Regards,

Tony
0
Erlend
Top achievements
Rank 1
answered on 27 Aug 2014, 08:55 AM
I had the same problem, and used Width as suggested above on Column:
<telerik:GridViewDataColumn DataMemberBinding="{...}" Header="{...}" IsReadOnly="True" Width="*"/>

But this causes strange behavior when the user drags to resize the column headers of other cells next to the stretched column. Any other way of achieving column stretch of a specific column without destroying column resize behaviour?
0
Dimitrina
Telerik team
answered on 28 Aug 2014, 01:07 PM
Hello,

Generally if you have a column with Width="*", then you should be able to still re-size any of the columns. Would you please share more details or a demo project on this strange behavior you experience?

Regards,
Didie
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
SF
Top achievements
Rank 1
answered on 18 Dec 2014, 03:08 PM

Hello,

I think we are experiencing the same stringe behavior as Erlend.
It can be simulated with your WPF Controls Examples application: GridView Examples, Example 'Custom Sorting'.
When there is a combination of columnwidth Auto and *, the resizing is strange:

- Trying to make the columns City, Country or Phone larger fails and other columns collapse
- Trying to extend the company name results into flickering

We would like to have the following behavior:
- If there are too many columns, a horizontal scrollbar should appear (this is probably not possible with star column width?)
- When resizing, only the current column should resize
- When there are few columns, they should stretch to fill the full grid width

The closest I get is to set all column widths to auto, then the first 2 issues are handled.
Is there a possibility to handle all issues?

0
Dimitrina
Telerik team
answered on 22 Dec 2014, 04:03 PM
Hi,

As it turns out I cannot suggest you a solution to achieve all three points. Currently, we have an issue logged into our system regarding:
​After column with width=* is resized to it's minimum width, it cannot be resized to a larger width.
Still, this issue is still not resolved.

Regards,
Dimitrina
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.

 
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Tony
Top achievements
Rank 1
Erlend
Top achievements
Rank 1
SF
Top achievements
Rank 1
Share this question
or