Modifying Report Manager and the ReportViewer controls

Say the following line in that voice of the guy that announces monster truck rallies: 

Are you ready for code that is going to BLOW YOUR MIND???? 

Too bad, because you’re getting this instead.

I was tasked to make the Reporting Services ReportViewer control look the same as the one in Report Manager. The ReportViewer looked like this:

ReportViewer

ReportViewer

And reports in Report Manager looked like this:

Report Manager

Report Manager

Most of the work was done with ReportViewer, removing buttons or rearranging them. So in the code behind for the page that held the ReportViewer (and in the following code, “rvReport” is a Microsoft.Reporting.WinForms.ReportViewer control):

            ToolStrip toolStrip = (ToolStrip)rvReport.Controls.Find(“toolStrip1”, true)[0];

            ToolStripItem refresh = toolStrip.Items[10];
            ToolStripItem print = toolStrip.Items[12];
            ToolStripItem export = toolStrip.Items[15];

            for (int i = 0;i < 10; i++)
            {
                toolStrip.Items.RemoveAt(7);
            }
            
            toolStrip.Items.Insert(12, export);
            toolStrip.Items.Insert(13, refresh);
            toolStrip.Items.Insert(14, print);

What? What’s with calling RemoveAt(7) ten times? Well, there were ten controls that needed to be removed between the page navigation arrows on the left side of the ReportViewer and the zoom control. I know, it doesn’t look like there are ten, but there are.

But my important, life-changing work wasn’t done. No no, there was more fun to be had because the Atom feed button was still lurking on the Report Manager screen. So to get rid of that travesty, I had to change the Report Server configuration file, HtmlViewer.css. My file was located at C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\Styles.

Track down the ToolbarAtomDataFeed style and change it’s display from inline to none:

.ToolbarAtomDataFeed
{
 display: none;
}

You’re probably out of breath because of the non-stop excitement that was this post. But you can get a breather now, until the next awesome post. Enjoy the rest.

Advertisements
  1. #1 by adil on November 2, 2012 - 7:19 am

    Thx for the info mate. I was very struggling while coding this. This gonna help me so much . BOokmarked!

  2. #2 by rokxer on December 28, 2013 - 6:06 pm

    This page should be sticky for everyone looking at ReportViewer! Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: