Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

Can Report (rdlc) Table or Matrix Column Width Be Set at Runtime?

$
0
0

Using an rdlc report in ReportViewer, I need to create a table or matrix where the number of columns and the kinds of data displayed in the columns changes with each report.  For example, in one report, the second column may hold price information.  In another report, the second column may hold a product description.

Obviously, a column with descriptive text needs to be wider than a column with price info. So, the column widths can't be firmly set in the designer.  But, I can't figure out how to change the column width during runtime, in either the Table control or Matrix control.  (I prefer the matrix, but can use either.)

Setting the header or details textbox CanGrow property to true doesn't help for two reasons.  One is that (in a Table control) the textbox grows in width only to the first linebreak opportunity (a space between words).  The other is that we need to export the report to PDF and even if the CanGrow widens the column in the viewer, when exported to PDF the column returns to the design width.

Tried setting the Width property of the column to an expression, but it wouldn't let me.

Spent a week on this.  Is it possible?  If not, if I switched to a Crystal Report (don't want to, I'm Crystal-Report challenged), is there a way to make it work?

There is one very ugly workaround: the Hidden property of a table column can be set to an expression.  I could set up the table with two or three columns of different widths for each column in the final report.  Depending on the column header ('Price', 'Description', etc.), certain columns would be hidden based on how wide a column was needed.  For example, there could be two design columns (one narrow, one wide) for column two of the final report.  If the heading on column 2 is Description, make the narrow column hidden so only the wide column displays with the Description text.

Seems it would be better to set the column widths, if possible.

Thanks.


Viewing all articles
Browse latest Browse all 1418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>