....................................
//this.Class2BindingSource.DataSource = typeof(List<Test0.Class2>);
this.Class2BindingSource.DataSource = print;
this.reportViewer2.LocalReport.EnableExternalImages = true; //打开图片支持
this.reportViewer2.LocalReport.ReportEmbeddedResource = @"Test0.Report2.rdlc"; //加载报表
this.reportViewer2.SetDisplayMode(DisplayMode.PrintLayout);
this.reportViewer2.ZoomMode = ZoomMode.Percent;
this.reportViewer2.ZoomPercent = 100;
//this.reportViewer2.Refresh();
string DeviceInfo = "<DeviceInfo><OutputFormat>EMF</OutputFormat></DeviceInfo>";
Warning[] warnings;
this.reportViewer2.LocalReport.Render("Image", DeviceInfo, CreateStream, out warnings);
printDocument1.Print();
}
//CreateStream Function:
private System.IO.Stream metafile_streams = new System.IO.MemoryStream();
private System.IO.Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
System.IO.Stream stream = new System.IO.MemoryStream();
metafile_streams = stream;
return stream;
}
//printDocument1 Code:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
metafile_streams.Position = 0;
System.Drawing.Imaging.Metafile pageImage = new System.Drawing.Imaging.Metafile(metafile_streams);
e.Graphics.DrawImage(pageImage, 0, 0);
m_streams.Close();
}
//multi-page Print:
TBC...