Show/hide a column in crystal report with condition

34 Views Asked by At

I have a requirement in crystal report to display/hide specific column. I am trying to control the object by suppress condition. But when the column is to be hidden it shows an empty space (which looks wierd). Is there anyway I can manage such columns so that it does not occupy space when not to be shown and allow the previous column to take its space.

I am stuck with crystal report version 13.

2

There are 2 best solutions below

0
MilletSoftware On

If the number of different column configurations is reasonably small, you can create a different detail section for each (Details a, Details b, ...) and then use a conditional expression for the Suppress property of each section to hide all but one of these sections.

0
JayBee On

I'm assuming your columns are side by side, together in the same Details section. In order to make the column to the left (column A) expand to fill the empty space created by the suppressed field (column B), you can go to column A's Size and Position settings, then use the formula option for the Width. The formula you use depends on how you've set column B to be suppressed. [I've used a parameter field (let's call it {?Show Column B} to allow the user to choose whether to conditionally suppress a column (and its field heading/label), and a Suppress formula on Column B and its field heading/label's Format Field options, which says suppress them if the parameter field value = 'No']

Therefore my Width formula for column A would be something like: If {?Show Column B} = "No" then 700 else 0

so that if Column B is suppressed, Column A's width expands by 700 twips to fill the space Column B would otherwise occupy.

I believe 1cm = 576 twips. More info about twips here: Crystal reports Text object control left property measurement