C#打印问题 20
在C#编程中,有一块我使用的第三方控件SoftwareFX.ChartFX.Lite来画柱状图,现在我需要打印这个柱状图,请问一下如何编写代码?急需,希望了解的人给些帮助...
在C#编程中,有一块我使用的第三方控件SoftwareFX.ChartFX.Lite来画柱状图,现在我需要打印这个柱状图,请问一下如何编写代码?急需,希望了解的人给些帮助,在线等。如果能够解决,我会另外加分的。
展开
1个回答
展开全部
添加printDocument1,printDialog1, pageSetupDialog1,printPreviewDialog1控件
//打印设置
private void btnSetPrint_Click(object sender, EventArgs e)
{
this.pageSetupDialog1.ShowDialog();
}
//打印预览
private void btnPrePrint_Click(object sender, EventArgs e)
{
this.printPreviewDialog1.ShowDialog();
}
//打印
private void btnPrint_Click(object sender, EventArgs e)
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
this.printDocument1.Print();
}
}
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-------------------*/
//Bitmap _NewBitmap = new Bitmap(groupBox1.Width, groupBox1.Height);
//groupBox1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
//e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
//Bitmap _NewBitmap = new Bitmap(groupBox1.Width, groupBox1.Height);
//groupBox1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
//e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
///*---------------------打印内容 为 自定义文本内容 -------------------*/
Font font = new Font("宋体", 12);
Brush bru = Brushes.Blue;
for (int i = 1; i <= 5; i++)
{
e.Graphics.DrawString("Hello world ", font, bru, i * 20, i * 20);
}
}
//打印设置
private void btnSetPrint_Click(object sender, EventArgs e)
{
this.pageSetupDialog1.ShowDialog();
}
//打印预览
private void btnPrePrint_Click(object sender, EventArgs e)
{
this.printPreviewDialog1.ShowDialog();
}
//打印
private void btnPrint_Click(object sender, EventArgs e)
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
this.printDocument1.Print();
}
}
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-------------------*/
//Bitmap _NewBitmap = new Bitmap(groupBox1.Width, groupBox1.Height);
//groupBox1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
//e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
//Bitmap _NewBitmap = new Bitmap(groupBox1.Width, groupBox1.Height);
//groupBox1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
//e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
///*---------------------打印内容 为 自定义文本内容 -------------------*/
Font font = new Font("宋体", 12);
Brush bru = Brushes.Blue;
for (int i = 1; i <= 5; i++)
{
e.Graphics.DrawString("Hello world ", font, bru, i * 20, i * 20);
}
}
追问
我想问如何编写打印第三方控件“chart”生成的柱状图?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询