User (Old forums)MemberSeptember 11, 2008 at 3:04 pmPost count: 23064
Supposedly in version 3.0 columns can be set to autosize to fit content.
Can someone point me where to look at how to do this?
Imported from legacy forums. Posted by justin (had 1257 views)Xceed SupportMemberSeptember 12, 2008 at 8:16 amPost count: 5658
To fit the width of a column to its content requires that you call GetFittedWidth and set the value to the Width property of the column. Other options are to set “*” values to the Width property or to set the ColumnStretchMode, which is defined on the TableView class.
Imported from legacy forums. Posted by Jenny [Xceed] (had 419 views)User (Old forums)MemberSeptember 26, 2008 at 6:26 amPost count: 23064
I tried using following code but always get GetFittedWidth as -1, so it’s not worth for me. Is there any other approach we can follow.
private void AdjustColumnWidth(Xceed.Wpf.DataGrid.DataGridControl grid)
foreach (Column column in grid.Columns)
double width = column.GetFittedWidth();
if (width > 0)
column.Width = width;
I can do with looping all columns and and calculating value after completing binding but it will make slow my application.
Imported from legacy forums. Posted by Mayank (had 949 views)Xceed SupportMemberSeptember 26, 2008 at 12:45 pmPost count: 5658
When are you attempting to call the GetFittedWidth method? Do you have columns that are not visible?
Imported from legacy forums. Posted by Jenny [Xceed] (had 461 views)User (Old forums)MemberSeptember 29, 2008 at 11:59 amPost count: 23064
Can you please post some sample code in order to get this working? This is really important for us at this point.
Also, the piece of code Mayank posted, is this the way to go in your opinion?
Thank you for your help,
Imported from legacy forums. Posted by Franck (had 1015 views)Xceed SupportMemberSeptember 29, 2008 at 3:03 pmPost count: 5658User (Old forums)MemberOctober 2, 2008 at 12:22 amPost count: 23064User (Old forums)MemberJanuary 26, 2010 at 9:26 amPost count: 23064
This post might help too: http://www3.xceed.com/CS/forums/permalink/25546/25546/ShowThread.aspx#25546
Imported from legacy forums. Posted by Neo (had 1158 views)tchien69ParticipantMay 6, 2017 at 12:39 amPost count: 1
1. The 1st 2 Links above get routed to “http://forums.xceed.com/forums/“. The 3rd Link’s Site doesn’t even exist.
2. I tried calling GetFittedWidth in the DataGridControl.ItemsSourceChangeCompleted Event (to use it to set Column.Width), but GetFittedWidth is returning -1. I’m using AutoCreateColumns, but the Column.Width’s are just a little narrower than what they need to be.
- You must be logged in to reply to this topic.