-
Notifications
You must be signed in to change notification settings - Fork 204
WinForms Viewer
Peter Gill edited this page Jun 7, 2026
·
2 revisions
dotnet add package Majorsilence.Reporting.RdlViewerThis is the most simple example of using the RdlViewer control. It loads a report with no parameters. Call RdlEngineConfig.RdlEngineConfigInit() once at application startup, then use SetSourceFile and Rebuild (both async) to load the report.
using System.Windows.Forms;
using Majorsilence.Reporting.Rdl;
using Majorsilence.Reporting.RdlViewer;
class ReportForm : Form
{
private readonly RdlViewer _rdlView;
public ReportForm()
{
Height = 600;
Width = 800;
_rdlView = new RdlViewer();
_rdlView.Dock = DockStyle.Fill;
Controls.Add(_rdlView);
Load += async (s, e) => await LoadReportAsync();
}
private async Task LoadReportAsync()
{
await _rdlView.SetSourceFile(new Uri(@"\path\to\your\report.rdl"));
await _rdlView.Rebuild();
}
}
class Program
{
[STAThread]
static void Main()
{
// One time per app instance
RdlEngineConfig.RdlEngineConfigInit();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ReportForm());
}
}This example loads a report with parameters. Set Parameters before calling Rebuild.
using System.Windows.Forms;
using Majorsilence.Reporting.Rdl;
using Majorsilence.Reporting.RdlViewer;
class ReportForm : Form
{
private readonly RdlViewer _rdlView;
public ReportForm()
{
Height = 600;
Width = 800;
_rdlView = new RdlViewer();
_rdlView.Dock = DockStyle.Fill;
Controls.Add(_rdlView);
Load += async (s, e) => await LoadReportAsync();
}
private async Task LoadReportAsync()
{
await _rdlView.SetSourceFile(new Uri(@"\path\to\your\report_with_parameters.rdl"));
_rdlView.Parameters += string.Format("&TestParam1={0}&TestParam2={1}", "Value 1", "Value 2");
await _rdlView.Rebuild();
}
}
class Program
{
[STAThread]
static void Main()
{
// One time per app instance
RdlEngineConfig.RdlEngineConfigInit();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ReportForm());
}
}using System.Windows.Forms;
using fyiReporting.RDL;
using fyiReporting.RdlViewer;
class Program
{
[STAThread]
static void Main()
{
System.Windows.Forms.Form frm = new System.Windows.Forms.Form();
frm.Height = 600;
frm.Width = 800;
fyiReporting.RdlViewer.RdlViewer rdlView = new fyiReporting.RdlViewer.RdlViewer();
rdlView.SourceFile = new Uri(@"\path\to\your\report.rdl");
rdlView.Rebuild();
rdlView.Dock = DockStyle.Fill;
frm.Controls.Add(rdlView);
Application.Run(frm);
}
}