Home Forums WinForms controls Xceed Grid for WinForms Autofit Columns Reply To: Autofit Columns

User (Old forums)
Member
Post count: 23064

I found the best way to do this was to run the following against the column after the DataSource has been assigned (“control” is and Xceed.Grid.GridControl)

control.Columns[“ColumnName”].Width = control.DataRows.Cast<Xceed.Grid.DataRow>().Max(r => r.Cells[“ColumnName”].GetFittedWidth());

Note: you need to be using Visual Studio 2008 or above and use the LINQ assemblies….

Craig

Imported from legacy forums. Posted by Craig (had 587 views)