I have a Windows form with Report Viewer in it. Currently, I am only able to print using Print icon available on top of the form. I have set the Report to an .rdlc file in design time for Report Viewer control. This is my code in Load event of a form:
private void BillViewer_Load(object sender, EventArgs e)
{
//datas passed to DataSet
this.reportViewer1.RefreshReport();
}
private void BillViewer_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.P)
{
//print report
}
}
On KeyDown event, I want to print the Report that is loaded in ReportViewer control. How can I do so? Thanks in advance.
You can print
like this
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if ((e.Key == Key.P) && (Keyboard.IsKeyDown(Key.LeftCtrl) ||
Keyboard.IsKeyDown(Key.RightCtrl)))
reportViewer.PrintDialog();
}