C#打印panel控件中内容
2012-10-18 13:10
288 查看
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]//应用API函数 private static extern bool BitBlt( IntPtr hdcDest, // 目标设备的句柄 int nXDest, // 目标对象的左上角的X坐标 int nYDest, // 目标对象的左上角的X坐标 int nWidth, // 目标对象的矩形的宽度 int nHeight, // 目标对象的矩形的长度 IntPtr hdcSrc, // 源设备的句柄 int nXSrc, // 源对象的左上角的X坐标 int nYSrc, // 源对象的左上角的X坐标 System.Int32 dwRop // 光栅的操作值 ); Image memoryImage; //统计报表画图 //打印按钮事件 private void button_print_Click(object sender, EventArgs e) { Graphics graphic = panel_Total.CreateGraphics(); Size s = panel_Total.Size; Bitmap memImage = new Bitmap(s.Width, s.Height, graphic); Graphics memGraphic = Graphics.FromImage(memImage); IntPtr dc1 = graphic.GetHdc(); IntPtr dc2 = memGraphic.GetHdc(); BitBlt(dc2, 0, 0, panelReports.ClientRectangle.Width, panelReports.ClientRectangle.Height, dc1, 0, 0, 13369376); //Clone the bitmap so we can dispose it. memoryImage = (Bitmap)memImage.Clone(); graphic.ReleaseHdc(dc1); memGraphic.ReleaseHdc(dc2); graphic.Dispose(); memGraphic.Dispose(); memImage.Dispose(); PrintPreviewDialog dlg = new PrintPreviewDialog(); //dlg.Width = 1800; //dlg.Height = 1600; //dlg.Document = printDocument1; //if (dlg.ShowDialog() == DialogResult.OK) printDocument1.Print(); } //printDocument 事件 private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) { e.Graphics.DrawImage(memoryImage, -10, 100); }
相关文章推荐
- HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容
- C#打印控件内容
- c# winform 打印 窗体 及 窗体控件内容 的 初级尝试
- HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容
- c#.net 文本编辑控件——使用 Visual C# .NET 打印 RichTextBox 控件的内容
- HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容
- C#打印控件内容,控件快照
- 在VS2008中使用C#代码打印 RichTextBox 控件的内容[方法采自微软支持][Part 1]
- HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容
- 在VS2008中使用C#代码打印 RichTextBox 控件的内容[方法采自微软支持][Part 2]
- C#代码 打印WinForm中Panel的内容
- 【C#】打印控件中的内容和打印窗体中的内容
- HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容
- 在C#中使用Panel控件实现在一个窗体中嵌套另一个窗体
- C#Winform基础 显示选中行的第一列单元格的内容,datagridview控件
- C# 打印groupbox的内容
- C#读取Excel表格中内容并显示在DataGridView控件中
- C# 调用带参数的控制台程序 并将命令行输出的内容实时输出至窗体中的显示控件
- C# panel控件实现鼠标滚轮滚动拖动滚动条
- C#下使用第三方开源控件读取Excel文件的内容