在Visual C#.net中打印图表 [英] Printing charts in Visual C#.net

查看:70
本文介绍了在Visual C#.net中打印图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我需要动态创建折线图。点数可以达到1000,间隔为1分钟。

I am developing an application in which I  need to dynamically create line chart. The number of points can go upto 1000 with an interval of 1 minute.

我已启用滚动属性,因此它会显示滚动条,因为它会继续添加数据点。现在我想打印包含所有数据点的完整图表。 

I  have enabled the scrolling property so it shows the scrollbar as it keeps on adding the data points. Now I want to print t he complete chart with all the data points. 

我尝试使用以下代码进行打印:

I tried to print using the following code:

private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            // Create and initialize print font 
            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            // Create Rectangle structure, used to set the position of the chart Rectangle 
            //System.Drawing.Rectangle myRec = new System.Drawing.Rectangle(10, 30, 150, 150);
            System.Drawing.Rectangle myRec = new System.Drawing.Rectangle(10, 10, 1000, 500);
            // Draw a line of text, followed by the chart, and then another line of text 
            ev.Graphics.DrawString("Line before chart", printFont, Brushes.Black, 10, 10);
            dataChart.Printing.PrintPaint(ev.Graphics, myRec);
            ev.Graphics.DrawString("Line after chart", printFont, Brushes.Black, 10, 500);
        }


System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();

            PrintDialog printDialog1 = new PrintDialog();
            // Add a PrintPageEventHandler for the document 
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);

            printDialog1.AllowSomePages = true;
            printDialog1.ShowHelp = true;

            printDialog1.Document = pd;

            DialogResult result = printDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                pd.Print();
            }

然而,它只打印图表的当前视图,但我想打印完整的图表所有数据点。

However it only prints the current view of the chart but I want to print the complete chart with all the data points.

有人可以帮我打印完整的图表。我正在使用visual studio 2010。

Can someone help me in to print the complete chart. I am using visual studio 2010.




推荐答案

您好,

作为文件  "图表打印"显示,"打印方法"只会打印当前数据视图。

As the document Chart Printing shows, the print method will only print the current data view.

由于此问题主要与图表控件相关,可能是其他社区有一些解决方案,我将帮助您将此线程移至
.NET Framework图表控件 论坛以获得支持。

Since this issue is mainly related to Chart control and maybe the other communities have some solutions, I will help you move this thread to Chart Controls for .NET Framework forum to get support.

问候,

Carl


这篇关于在Visual C#.net中打印图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆