开发者

crystal report dynamic column and .net

sup开发者_Python百科pose my report has 10 column and at run time how could i show and hide column writing the code. need help.


Fields in Crystal Reports are bundled using horizontal sections (Report Headers, Page Headers, Group Headers, Details, Group Footers, Page Footers, and Report Footers) and not using vertical alignments (columns). Most reports display columnar fields by aligning their horizontal positions but there is no intrinsic column-grouping in Crystal Reports.

To dynamically hide a column of fields at run-time, the Suppress flag can be set using a Boolean conditional formula:

  • On the Design view, highlight all fields belonging to the column,
  • right-click on one of them,
  • select Format Objects... from the context-menu
  • go to the Common tab,
  • click on the X-2 icon corresponding to the Suppress checkbox,
  • the Format Formula Editor - Suppress window will open,
  • input a formula that results to True or False.

At run-time, the fields will either display or not depending on the result of the formula. However, white space will still appear in the suppressed column fields' position and fields to the right of will still be positioned in the same spot. To make the columns to the right slide to the left, their X-Position needs to be dynamic as well:

  • right-click one of the fields belonging to the column to the right,
  • select Size and Position...,
  • click on the X-2 icon corresponding to the X: textbox,
  • the Format Formula Editor - X-Position Adjustment window will open,
  • input a formula that results to the number of twips to be adjusted,
  • repeat for all other fields belonging to the column to the right.

A Twip is equivalent to 1/1440 of an inch. Since the field's position should slide to the left, the result of the formula should be negative (a positive value will slide the field to the right). For example, if the field should slide left 2 inches, then the formula result should be -2880.

Note that you'll need to incorporate the same condition on the Suppress for the left field into the formula for X-Position Adjustment of the right field:

  • If the left field is not suppressed, then x-position adjustment of the right field should be 0.
  • If the left field is suppressed, then x-position adjustment of the right field should be equal to the width in twips of the left field.

I haven't found any good Crystal Reports Tips & Tricks book yet so I can only recommend reading the Crystal Reports User Guide available from SAP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜