ComponentOne VSView Reporting Edition
OnPrint Event

Fired before the Section is printed (after it is formatted.)


Private Sub VSReport_OnPrint( ByVal SectionIndex As Long)


You can use this event to build report elements as the report is generated. The event is similar to the Section object's OnPrint property, which contains a VBScript string that gets executed when a section is rendered. The difference between the two is that the traditional event handler is implemented by the application that is rendering the report, and the VBScript event is implemented within the report itself, and is therefore viewer-independent.

For example, the code below generates a chart and assigns it to a field in the report:

Private Sub vsr_OnPrint(ByVal SectionIndex As Long)


  ' get the field we want to render as a chart

  Dim theField As Field

  Set theField = vsr.Fields("SalesChart")


  ' make sure this is the section we want

  If theField Is Nothing Then Exit Sub

  If SectionIndex <> theField.Section Then Exit Sub


  ' create chart and copy it to the clipboard



  ' paste chart into report field

  theField.Picture = Clipboard.GetData(vbCFMetafile)

End Sub



Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback