日期:2014-05-17 浏览次数:20901 次
public partial class print : Form
{
public print()
{
InitializeComponent();
this.printDocument1.OriginAtMargins = true;//启用页边距
this.pageSetupDialog1.EnableMetric = true; //以毫米为单位
}
private void button3_Click(object sender, EventArgs e) //打印设置
{
this.pageSetupDialog1.ShowDialog();
}
private void button2_Click(object sender, EventArgs e) //打印
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
this.printDocument1.Print();
}
}
private void button1_Click(object sender, EventArgs e) //打印预览
{
printDialog1.Document = printDocument1;
this.printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
////打印内容 为 整个Form
//Image myFormImage;
//myFormImage = new Bitmap(this.Width, this.Height);
//Graphics g = Graphics.FromImage(myFormImage);
//g.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, this.Size);
//e.Graphics.DrawImage(myFormImage, 0, 0);
//打印内容 为 局部的 this.groupBox1
&nbs