Currently, XRTable does not provide the best fit column functionality for several reasons. It is not quite clear how this feature should work in the case of multi-line text in cells. Being applied to a grid, the best-fit feature resizes grid columns so you can use the horizontal scrollbar to reach all of them. Reports does not provide interactivity like content scrolling and it is difficult to foresee how a user would want to change the report layout in the case of large column content.
For these reasons, a generic solution is not always possible. However, we can implement this manually if required. This example demonstrates how to do so.
Here are implementation details.
1. Create a document by using the Report's CreateDocument Method.
2. Iterate through all report bricks to obtain the maximum text width within a certain column.
Since XRTable rows act independently and know nothing about each other, to detect the max width of the text in a certain column, we need to iterate through report table bricks manually (for instance, using BricksIterator) and calculate the text width (using the PrintingSystem.Graph.MeasureString method).
3. Re-set the XRTableCell's WidthF property according to calculation results.
4. Re-create the report document.
See also:
How to set the label width so that it is always equal to its text (AutoWidth)