Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Alternating Color on Crosstab Rows
In Crystal Reports 8.5 it "isn't possible" to alternate row color on a CrossTab. However, as usual with Crystal, there are plenty of workarounds.
For me, most of my crosstabs always have the same number of rows, with variable numbers of fixed width columns.
Workaround?
Create a Picture which is a light grey box, and move it behind every other row. (Send to back.) Then, in the code that calls the report (C#/.NET), you can dynamically set the width of the box to match the number of columns you have:

// set row shading width.
foreach(CrystalDecisions.CrystalReports.Engine.ReportObject reportObj in report.reportDocument1.ReportDefinition.ReportObjects)
{
if(reportObj.Kind == CrystalDecisions.Shared.ReportObjectKind.PictureObject)
{
CrystalDecisions.CrystalReports.Engine.PictureObject box = (CrystalDecisions.CrystalReports.Engine.PictureObject)reportObj;
box.Width = 1000+cols*500; //(label width + x for each column)
}
} // FORMAT lines

Note that you may be tempted to use a BoxObject, but setting the Width of a BoxObject dynamically is not allowed. Also, make SURE you are decreasing the width of the picture box (put it on the report at maximum width). Stretching the box doesn't seem to work.

So theoretically, you could enhance this by dynamically creating (or moving) a series of pictures to handle the case of multiple rows as WELL as multiple columns. Good luck with that! I'll post it if I ever need to come up with the algorithm.

Created By: amos 3/20/2006 12:12:59 AM