About Me

My photo
Software Developer and ideas man!

Tuesday, June 7, 2011

Ever wanted to turn off the drill down capability on subreports.

Here are 2 simple ways of turning off the drilldown capability on a subreport. In the code below, I've performed the cast to expose other methods and properties of the args parameter [the cast is unnecessary though].


private void CRViewer_DrillDownSubreport(object source, CrystalDecisions.Windows.Forms.DrillSubreportEventArgs e)
        {
            (e as CrystalDecisions.Windows.Forms.ViewerEventArgs).Handled = true;
        }

Note -  this code can be useful if you wanted to enable or disable the drilldown for a particular subreport.



The drilling down in the CR viewer can also be turned off by setting "EnableDrilldown" to false in the properties of the viewer which is less flexible given it is in place for all reports.



More from this Blogger:
Localizing Crystal Reports in C# - I demonstrate one way of doing it despite the hurdles!

Look - I can't read the x-axis labels on my CR Chart!

Ever had the problem with your Crystal Report charts where the datapoints on your chart are too numerous and the x-axis labels become illegible because they all become scruntched up together.  This is primarily for charts that have greater than 100 datapoints.

Well I did and posted the Sap forums for an answer -
http://forums.sdn.sap.com/thread.jspa?threadID=1922787&tstart=0

Anyway, I was forced to come up with an alternative approach for my stacked area and line charts using the charts shipped with Crystal. 

What I did was develop 2 charts to display the same information.  One of the charts was suppressed depending on the number of datapoints to be plotted - so if the number of datapoints exceeded 20 datapoints, I suppress the chart that has the "Show Group Axis" option enabled - this appears to be the sweet spot for readability for my charts using the system default datetime formatted axis label.


With the chart that has the "Show Group Axis" unchecked, I then inserted "Summary" text boxes below the x-axis to display the Minimum and Maximum datetimes for the datapoints.  This set the start and end axes points and lined up perfectly with the start and end of the chart.  As with the duplicate chart, these were suppressed if the number of datapoints was less than 20.

I then inserted a "Data date" field in the middle of the x-axis to indicate the middle datetime for the datapoint range and inserted the following script for the "Display string".

 
So this report  


became
Let me know if you find this useful or need further info on any of the steps above.  

P.S. One further note - I am using Crystal Reports 13.0.1.220 targetted at Visual Studio 2010.