Click here to Skip to main content
Click here to Skip to main content

A Workaround to Customizing and Localizing the Microsoft ReportViewer .NET Toolbar

, 25 May 2006
Rate this:
Please Sign up or sign in to vote.
An article about how to customize and localize the Microsoft ReportViewer Toolbar.

ReportViewer Toolbar

Introduction

Microsoft released a new component called ReportViewer based on the new RDL technology. Since this is a new component, there are not enough samples about it. There are many questions about how to localize and customize the ReportViewer toolbar, in some forums. Some developers want to add a help button on it, some people want to localize it for Turkish etc.

What is RDL - Report Definition Language

A report definition contains data retrieval and layout information for a report. Report Definition Language (RDL) is an XML representation of this report definition. RDL is an open schema; developers can extend RDL with additional attributes and elements.

The standard file extension for report definition files is .rdl. Its MIME type is text/xml.

More resources about RDL

Background

The best way to localize and customize the ReportViewer toolbar is to hide it and implement its methods in your own code. This article is simply based on this idea.

Using the code

You can simply hide the ReportViewer toolbar, like this:

repView.ShowToolBar = false;

This will completely hide the ReportViewer toolbar. Then add your own toolstrip and implement the necessary methods.

To find a string in the report:

private bool frmCmdFind()
{
    int found = this.repView.Find(txtSearch.Text, 1);
    if (found > 0)
    {
        btnFindNext.Enabled = true;
    }
    else
    {
        MessageBox.Show("Searched string not found", 
                        "Info", MessageBoxButtons.OK, 
                        MessageBoxIcon.Information);
        btnFindNext.Enabled = false;
    }
    return true;
}

To exporting a report as an Adobe Acrobat PDF file:

private bool frmCmdPdf()
{
    LocalReport lr = this.repView.LocalReport;
    lr.ReportPath = this.repView.LocalReport.ReportPath;
    string outputFile = this.ReportDisplayName + ".pdf";
    File.Delete(outputFile);
    Warning[] warnings;
    string[] streamids;
    string mimeType = "";
    string encoding = "";
    string extension = "";

    deviceInfo = "";

    byte[] bytes = lr.Render("PDF", deviceInfo, out mimeType, 
                             out encoding, out extension, 
                             out streamids, out warnings);

    FileStream fs = new FileStream(outputFile, FileMode.Create);
    fs.Write(bytes, 0, bytes.Length);
    fs.Close();
    System.Diagnostics.Process p = new System.Diagnostics.Process();
    p = new System.Diagnostics.Process();

    p.StartInfo.FileName = outputFile;
    p.Start();
    return true;
}

For full implementation, see the source file above.

Conclusion

Microsoft ReportViewer is a powerful component to display your report, and RDL is a good way to implement the reporting features. I believe that in the near future, many RDL designer tools and RDL viewer tools will be available in the market.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

yincekara
Software Developer (Senior) MikroKom Yazilim A.S.
Turkey Turkey
c# , vb6 , mssql , oracle , mysql , asp , asp.net developer.

Comments and Discussions

 
QuestionCustomizing and Localizing the Microsoft ReportViewer .NET Toolbar web form Pinmemberdbongs27-Feb-14 23:21 
GeneralSimply way to customize report ToolBar Pinmembergeneral.jesiu5-Nov-09 8:42 
GeneralThanks, PinmemberS. Töpfer28-Sep-09 22:20 
GeneralRe: Thanks, Pinmemberyincekara29-Sep-09 1:09 
Your welcome Smile | :)
QuestionHow to invoke the pagesteup dialog box programatically PinmemberMember 429011810-Apr-08 6:57 
AnswerRe: How to invoke the pagesteup dialog box programatically Pinmemberyincekara29-Sep-09 1:23 
Generalcode licence Pinmembermarsu3622-Dec-07 22:29 
GeneralRe: code licence Pinmemberyincekara14-May-08 22:11 
GeneralRefreshing the Report Bounds Pinmemberf r i s c h13-Sep-07 3:17 
GeneralRe: Refreshing the Report Bounds Pinmemberyincekara13-Sep-07 3:32 
GeneralRe: Refreshing the Report Bounds Pinmemberf r i s c h13-Sep-07 21:33 
GeneralRe: Refreshing the Report Bounds Pinmemberyincekara13-Sep-07 21:58 
Generalshowing report in report viewer without using smart tags PinmemberMeSiddy16-Aug-07 6:37 
GeneralRe: showing report in report viewer without using smart tags Pinmemberyincekara16-Aug-07 7:50 
QuestionReportviewer Help Pinmemberabraylyan11-Mar-07 15:00 
AnswerRe: Reportviewer Help Pinmemberyincekara11-Mar-07 21:47 
GeneralReportViewer problem PinmemberKschuler29-Jan-07 8:31 
GeneralRe: ReportViewer problem Pinmemberpolymorphism8-Feb-07 2:32 
GeneralRe: ReportViewer problem PinmemberKschuler9-Feb-07 2:54 
GeneralRe: ReportViewer problem PinmemberAeroday19-Jul-07 6:16 
GeneralTurkish language PinmemberMaksi20-Nov-06 22:25 
GeneralRe: Turkish language Pinmemberyincekara20-Nov-06 22:58 
GeneralRe: Turkish language [modified] Pinmemberyincekara12-Feb-07 0:03 
Generallocalization [modified] Pinmemberlemravec14-Aug-06 8:16 
GeneralRe: localization Pinmemberpolymorphism20-Aug-06 23:26 
QuestionAnother approach PinmemberKoru.nl1-Jun-06 23:31 
AnswerRe: Another approach Pinmemberyincekara2-Jun-06 1:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140826.1 | Last Updated 25 May 2006
Article Copyright 2006 by yincekara
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid