Skip to content

Viewer and Toolstrip

Peter Gill edited this page Jun 8, 2026 · 7 revisions

Viewer Toolbar Control

ViewerToolstrip is a WinForms control that wraps RdlViewer and provides a standard report toolbar — open, save, print, zoom, and page navigation — without requiring you to build it yourself.

Install

dotnet add package Majorsilence.Reporting.RdlViewer

Adding to a form

Wire ViewerToolstrip to an existing RdlViewer by passing the viewer to the constructor, or by assigning it to the Viewer property:

// Option A — pass viewer to constructor
var rdlViewer1 = new Majorsilence.Reporting.RdlViewer.RdlViewer();
var reportStrip = new Majorsilence.Reporting.RdlViewer.ViewerToolstrip(rdlViewer1);

// Option B — assign after construction
var rdlViewer1 = new Majorsilence.Reporting.RdlViewer.RdlViewer();
var reportStrip = new Majorsilence.Reporting.RdlViewer.ViewerToolstrip();
reportStrip.Viewer = rdlViewer1;

After creating both controls, add them to your form. Place the toolstrip above the viewer:

// In the Form constructor or designer code
this.Controls.Add(reportStrip);   // top
this.Controls.Add(rdlViewer1);    // below

reportStrip.Dock = DockStyle.Top;
rdlViewer1.Dock = DockStyle.Fill;

Toolbar buttons

Button Action
Open Browse for an .rdl file and load it
Save Export the current report to PDF, Excel, or other format
Print Send the current report to a printer
Zoom In / Zoom Out Increase or decrease the display zoom level
Zoom selector Dropdown to select a specific zoom level (50%, 75%, 100%, 150%, 200%)
First Page Jump to page 1
Previous Page Go to the previous page
Page number box Shows the current page; type a number and press Enter to jump
Page count Shows the total number of pages
Next Page Go to the next page
Last Page Jump to the last page

Full form example

using Majorsilence.Reporting.Rdl;
using Majorsilence.Reporting.RdlViewer;

public class ReportForm : Form
{
    private RdlViewer _viewer;
    private ViewerToolstrip _toolstrip;

    public ReportForm(string rdlPath)
    {
        InitializeComponent();

        _viewer   = new RdlViewer   { Dock = DockStyle.Fill };
        _toolstrip = new ViewerToolstrip(_viewer) { Dock = DockStyle.Top };

        Controls.Add(_viewer);
        Controls.Add(_toolstrip);

        Load += async (s, e) => await LoadReportAsync(rdlPath);
    }

    private async Task LoadReportAsync(string rdlPath)
    {
        RdlEngineConfig.RdlEngineConfigInit();
        await _viewer.SetSourceFile(new Uri(rdlPath));
        await _viewer.Rebuild();
    }
}

Programmatic zoom

The toolstrip reflects viewer zoom changes automatically. You can also set zoom directly on the viewer:

_viewer.Zoom = 1.5f;   // 150%
_viewer.Zoom = 0.75f;  // 75%

Screenshot

Toolstrip screenshot

Working example

A complete sample application is available in the repository: Examples/Sample-Report-Viewer

Clone this wiki locally