In Reporting Services (version 2005) , the CanGrow property indicates whether the size of the text box can increase vertically according to its content. Similarly, CanShrink decreases the height of the text box according to its content. Controlling dynamically the height of report elements is only possible through these properties since the Height property cannot be bound to an expression. These two properties are therefore useful to create reports which can be scaled to both small and large contents. Unfortunately, CanGrow and CanShrink behave differently for each rendering extension.

Design Surface

Let’s demonstrate such behaviors with a report created with SSRS 2005. The following elements have been created without any padding:

  • A text box with a non-empty value (Value = "Content") and CanShrink set to true.
  • A text box with a non-empty value (Value = "Content") and CanGrow set to true.
  • A text box with a non-empty value (Value = "Content") where CanShrink and CanGrow are both set to true.
  • A text box with an empty value and CanShrink set to true.
  • A text box with a single space as value (Value = " ") where CanShrink is set to true.
  • A non-visible text box (Visibility.Hidden = true).
  • A non-visible text box where CanShrink is set to true.
Font Property

The FontSize property of each text box is bound to FontSize report parameter (= Parameters!FontSize.Value). The available values are 6pt, 10pt, 16pt, and 30pt.

Rendering Extensions

First, let’s have a look on how the report is rendered with IE 7.

IE7 6pt IE7 10pt
IE7 16pt IE7 30pt

CanGrow and CanShrink behave as expected for all the text boxes having a non-empty Value. The shrinkable text box cuts off content too big for the specified height. Similarly, the text box which can only grow has its height unchanged when the FontSize is equal to 10pt. Notice that the text box, which can shrink but has no value, does not have its height changed. The Value property needs to have a space to have its height resized to zero.

PDF 10pt

The PDF rendering is the most accurate. Similarly to the HTML rendering, the CanGrow and CanShrink modify the heights of the text boxes as expected. Furthermore, the text box with an empty Value has been removed from the flow of the document. On the other hand, the hidden text boxes continue to occupy some real-estate on the report. Combining the CanShrink property with just a space for the Value property does not, however, hide the text box contrarily to the HTML rendering.

Excel 10pt

Finally, it is obvious with the Excel rendering that the CanGrow and CanShrink properties fail to adjust the height of the Excel rows. It is a frustrating limitation of the Excel rendering.

Conclusions

When using CanGrow and CanShrink, be aware what their behaviors can change depending on the rendering extension being used:

  • CanShrink will remove the text box from the document flow for only specific rendering formats.
  • No Value property may cause some issues.
  • The Visibility property seems to override the intended behavior of CanShrink.
  • Padding needs to be set to zero to fully hide a shrinkable element.