C# winform 打印 请教:如何在winform中设置一个窗体,窗体的格式类似个人的简历,是个表格,里面有文本数据和图片。其中图片存在磁盘上,数据在数据库中。其格式就像 个人信息表。如何设置。用什么控件,如何实现,怎么做才能显示,并且打印。如果搞定还有分!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以考虑截屏,截取你整个WinForm窗体,保存成jpg图片,然后再打印(这时就可以用系统自带的打印功能了) 我个人建议楼主直接在窗体中用控件构建出你所要的个人信息表,然后可以打印出整个个人信息表窗体.参考代码如下:我不喜欢使用别人的控件,只是拿来学习,呵呵.当然这种控件也不知道怎么找,个人信息控件????using System;using System.Windows.Forms;using System.Drawing;using System.Drawing.Printing;public class Form1 : Form{ private Button printButton = new Button(); private PrintDocument printDocument1 = new PrintDocument(); public Form1() { printButton.Text = "Print Form"; printButton.Click += new EventHandler(printButton_Click); printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); this.Controls.Add(printButton); } void printButton_Click(object sender, EventArgs e) { CaptureScreen(); printDocument1.Print(); } //获取整个窗体的内容. Bitmap memoryImage; private void CaptureScreen() { Graphics myGraphics = this.CreateGraphics(); Size s = this.Size; memoryImage = new Bitmap(s.Width, s.Height, myGraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s); } private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawImage(memoryImage, 0, 0); } public static void Main() { Application.Run(new Form1()); }} 我想也许可以导入到excel中再打印。几年前我一次领某考试的准考证时发现准考证居然是用excel管理打印的,呵呵,可见其功能够强大,可能比找控件更方便些?? 关于TreeView中节点颜色问题,求高手解决 发现个奇怪的问题,编译器把if编译成else if谁发现过???? 关于SetCursorPos和WH_MOUSE_LL的问题 ◆都来看看,截字符串问题◆ 将一个大的格式文本(CSV)如何写入数据库? 关于得到Access数据库表中某一字段的数据类型和大小的问题 Team Foundation Server 速度慢 一个.Sort()排序的方法的调用问题? 静态变量的问题!很简单!<在线等候><当场给分> C# CSV 导入数据库 关于cookie登陆的问题 toolStrip 图片背景颜色
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Printing;public class Form1 :
Form
{
private Button printButton = new Button();
private PrintDocument printDocument1 = new PrintDocument(); public Form1()
{
printButton.Text = "Print Form";
printButton.Click += new EventHandler(printButton_Click);
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
this.Controls.Add(printButton);
} void printButton_Click(object sender, EventArgs e)
{
CaptureScreen();
printDocument1.Print();
} //获取整个窗体的内容.
Bitmap memoryImage; private void CaptureScreen()
{
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
} private void printDocument1_PrintPage(System.Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
public static void Main()
{
Application.Run(new Form1());
}
}
几年前我一次领某考试的准考证时发现准考证居然是用excel管理打印的,呵呵,可见其功能够强大,可能比找控件更方便些??