How to auto-size a DevExpress TcxGrid

Brian Frost picture Brian Frost · Dec 17, 2010 · Viewed 15.7k times · Source

I've created a table from a TcxGrid with a simple table view. The data is being poked into the table using DataController.Values[n,m] as a simple string and I have some 10 columns that will show various string widths.

The problem that I'm having is getting a table that has a horizontal scroll bar AND has auto-sized its columns. If I set CellAutoWidth true this fits all columns into the display width (with no scroll bar) but if I set it false, I get a scroll bar but columns of my default width and my data strings are truncated.

Could some kind person tell me how to get a horizontal scroll bar AND get each column to adjust its width to fit its max data width please?

Thanks Brian.

Answer

Uli Gerhardt picture Uli Gerhardt · Dec 17, 2010

Maybe it's enough to call YourGridView.ApplyBestFit instead of using CellAutoWidth.