Drilling into Report Details

If you are working with a report that has groups inserted, you can drill down within the viewer to show the detailed records that make up that group. By default, these details are visible anyway, as shown in Figure 4-25.

When you drill down into a group, a separate tab is opened within the preview window, showing only the group you have selected. For summary reports, you may want to hide the details and allow users to drill down if they need more information.

This provides an easy way to cut down on report development; instead of multiple reports for different regions, for example, you could create one report and then let the users drill into it and print the section they wanted to see. In the following example, the user has drilled down into Australia, which opens another tab in the viewer, allowing the user to see the regions within Australia.

When you double-click a group or summary and drill down into a report, the Drill event is fired and can be used to return the name of the group, the level, or other information. There are a number of properties associated with DrillEventArgs, including:

Figure 4-25




Returns the group level that was drilled into


Returns the name of the group that was drilled into


Returns the group number and group level that was drilled into


Returns the target group level that is being drilled into


Returns the target group name that is being drilled into


Returns the target group number and group level that is being drilled into

CurrentGroupNamePath and NewGroupNamePath are included within DrillEventArgs, but are reserved for future use.

To see the Drill event in action, you will need to have a report that has at least one group inserted and a section where the details are hidden (not suppressed). In addition, in the Crystal Report Viewer, the EnableDrillDown property must be True. The Drill event will fire whenever you drill down into one of the groups on your report and can be used to determine the group name and what level has been drilled into, among other things.

Drill events can be used to launch other forms or processes; for example, when a user drills down on a Country group, you could display a form giving a background to the country, its currency, and other pertinent information.

The following code demonstrates the Drill event being used to display an information box, containing information on where the user was drilling from and the target they were drilling to.

Private Sub CrystalReportViewer1_Drill(ByVal source As Object, ByVal MyEvent As CrystalDecisions.Windows.Forms.DrillEventArgs) Handles CrystalReportViewerl.Drill

MsgBox("You drilled into " & MyEvent.NewGroupName() & (Chr(13) & Chr(10)), MsgBoxStyle.Information, "Drill Down Event")

End Sub

Was this article helpful?

0 0

Post a comment