c# ms chart - 打印图表的最佳方式是什么? [英] c# ms chart - what is the best way to print a chart?
问题描述
我在表单上有一个 ms 图表控件,我想打印该图表.这样做的最佳方法是什么?
i have an ms chart control on the form and i would like to print the chart. what is the best way to do this?
推荐答案
这对于您的目的来说可能有点复杂,但我已经使用了 PrintDocument 对象在报表页面上绘制背景图像.您可以执行类似的操作,使用 PrintPageEventArgs 中的 Graphics 对象绘制"图表图像.
This might be a bit convoluted for your purposes, but I've used the PrintDocument object to draw a background image on pages of a report. You could do something similar, where you use the Graphics object from the PrintPageEventArgs to "paint" your chart image.
此代码将打印一个 1 页的文档,在上角绘制一个小矩形.我认为你可以用图表的绘图替换那里的绘图
This code would print a 1 page document with a small rectangle drawn in the upper corner. I would think you could replace the drawing there with the drawing of your chart
class Program
{
public class Document : System.Drawing.Printing.PrintDocument
{
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
base.OnBeginPrint(e);
}
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawRectangle(SystemPens.ActiveBorder, new Rectangle(0, 0, 20, 20));
}
}
static void Main(string[] args)
{
System.Drawing.Printing.PrintDocument pd = new Document();
pd.Print();
}
}
这篇关于c# ms chart - 打印图表的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!