views:

2875

answers:

2

Can someone please explain how to remove the background/borders off an embedded CrystalReportViewer control in Visual Studio 2008.

I'm trying to remove the light gray (below the "Crystal Report" heading) and then the darker gray underneath that. I want to be left with only the white box and the report inside this.

This is the output I'm currently getting:

http://img411.imageshack.us/my.php?image=screenshotml3.jpg

The HTML snippet is:

<div>
 <h2>Crystal Report</h2>

    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
    AutoDataBind="true" DisplayToolbar="False" />
</div>

The C# code snippet is:

string strReportName = "CrystalReport";
string strReportPath = Server.MapPath(strReportName + ".rpt");
ReportDocument rptDocument = new ReportDocument();
rptDocument.Load(strReportPath);
CrystalReportViewer1.HasCrystalLogo = false;
CrystalReportViewer1.HasDrilldownTabs = false;
CrystalReportViewer1.HasDrillUpButton = false;
CrystalReportViewer1.HasExportButton = false;
CrystalReportViewer1.HasGotoPageButton = false;
CrystalReportViewer1.HasPageNavigationButtons = false;
CrystalReportViewer1.HasPrintButton = false;
CrystalReportViewer1.HasRefreshButton = false;
CrystalReportViewer1.HasSearchButton = false;
CrystalReportViewer1.HasToggleGroupTreeButton = false;
CrystalReportViewer1.HasToggleParameterPanelButton = false;
CrystalReportViewer1.HasZoomFactorList = false;
CrystalReportViewer1.DisplayToolbar = false;
CrystalReportViewer1.EnableDrillDown = false;
CrystalReportViewer1.BestFitPage = true;
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
CrystalReportViewer1.BackColor = System.Drawing.Color.Red;
CrystalReportViewer1.BorderColor = System.Drawing.Color.Green;
CrystalReportViewer1.CssClass
CrystalReportViewer1.Height = 200;
CrystalReportViewer1.Width = 500;
CrystalReportViewer1.ReportSource = rptDocument;
+1  A: 

Your code worked for me in Visual Studio 2008 with the Crystal Reports XI Release 2 Developer Edition (stand-alone product). I had no visible gray bars or background. In fact, the white space of the report itself showed up as the assigned BackColor, Red. Are you using the bundled CrystalReportViewer that comes with Visual Studio 2008? It might be worth trying to set the BorderStyle property to BorderStyle.None to see if that has any effect.

There is a tutorial on MSDN about customizing the CrystalReportViewer control at: http://msdn.microsoft.com/en-us/library/ms227538.aspx

That's the one for VS2008/.NET 3.5, but I'm not sure how much the tutorial has actually changed from the previous version.

Matt V
A: 

I had the same problem.

It was caused by another CSS file conflicting with the control's CSS file.

Once I made a master file for reports, without all the site's CSS file references, the background and taskbar were fine - they have a white background.

Joe R