Skip to main content Skip to footer

How To: Hide a Specific Field on Printing C1Report

An important thing about a reporting tool is that it should be highly customizable so as to give the developers flexibility to design the reports in the way they want them to be. C1Report not just allows to create the reports easily in a few steps; the customizations and features it offers have also included it in the list of user friendly reporting tools. Usually, the reports are created using the designer and then the complete data is printed using the Print button available in the toolbar of C1PrintPreviewControl. What if the users wants to get the reports printed at their discretion? That essentially means, the users can decide which fields to be printed and which one to leave out. Ideally, the report being previewed in C1PrintPreviewControl is printed completely. However, you can also decide which fields you want to hide in the printed copy. Before we get into the implementation, let us take a look at how the report will look in C1PrintPreviewControl: Img_HididngAFieldOnPrinting The implementation includes the following steps: Enabling the user to choose the fields that should be hidden

  1. Create a Listbox that should have all the fields present in the report.
  2. Add two buttons to make the user able to select any field to hide and drop it in a second Listbox so as to isolate the fields whose Visibility should be set to false.

Handling the click of the print button present in C1PrintPreviewControl’s toolbar

  1. Capture the PreviewPrint event of C1Previewpane at run-time and cancel the printing operation.
  2. Create a new instance of the same C1Report and hide all the fields from it depending on the items present in the second Listbox.
  3. Create your own PrintDialog and print the new report .

For instance, if the user has chosen to hide the report's Title in the above previewed report, this is how it looks like on printing: PrintedCopy This would make the report previewed in C1PrintPreviewControl correctly with all the fields, however the fields as per the selection of user would be hidden in case the report is printed. Please refer to the attached samples for detailed implementation of the same: DownloadSample_CS DownloadSample_VB

MESCIUS inc.

comments powered by Disqus