Re: Dynamic Column widths
Data Dynamics Reports Support
Dynamic Column widths
08-18-2010, 3:49 PM
Hi,
I'm wondering if there is any way to set column width to fit the largest data point to be found in the column. I'm really hoping there is something equivalent to the "CanGrow" functionality that I see on TextBoxes that will allow this to happen automatically for a column.
Failing that, is there a way this can be done programmatically?
-Jason
Re: Dynamic Column widths
08-18-2010, 8:33 PM
Hello,
The table column width can't be changed at runtime. The value that is set at design time will be used. The only work around the question you posted that I can think about is the dynamic modification of the textbox's font size to fit the text.
Sergey Abakumoff
GrapeCity
Re: Dynamic Column widths
08-19-2010, 6:15 PM
Thanks Sergey. Could you please provide an example of how to perform this dynamic modification of the textbox's font size to fit the text inside the width of the column?
Thanks,
Jason
Re: Dynamic Column widths
08-19-2010, 9:34 PM
Hello,
The algorithm of scaling the font so that the text fits in the given rectangle(textbox in our case) is well-known, you can find the detailed description over the web, for example: http://www.switchonthecode.com/tutorials/csharp-tutorial-font-scaling
You can add the new function in the Code of a report. That function accepts the string to measure, the size of the textbox, the font family and returns the size of the font to set. Use the code similar to that shown in the article I pointed above.
Then call that function in the expression for the Font property of a textbox.
You can find more information about the report code at
http://www.datadynamics.com/Help/ddReports/ddrconCustomCode.html
Sergey Abakumoff
GrapeCity