如何将图表控件图片保存到文件?

时间:2022-07-11 16:51:16

Having a chart displayed with a System.Windows.Forms.DataVisualization.Charting.Chart control in a .Net 4.0 WinForms application, can I save its render into a picture file?

使用.Net 4.0 WinForms应用程序中的System.Windows.Forms.DataVisualization.Charting.Chart控件显示图表,我可以将其渲染保存到图片文件中吗?

2 个解决方案

#1


15  

How about the Chart.SaveImage() method?

Chart.SaveImage()方法怎么样?

#2


17  

You can use the code below by passing proper ChartImageFormat.*:

您可以通过传递正确的ChartImageFormat来使用下面的代码。*:

this.chart1.SaveImage("C:\\mycode\\mychart.png", ChartImageFormat.Png);

Also look this SO if you met any problem: Save Image Using .net Chart and Saving higher resolution charts without messing up the appearance

如果您遇到任何问题,请查看此消息:使用.net图表保存图像并保存更高分辨率的图表而不会弄乱外观

#1


15  

How about the Chart.SaveImage() method?

Chart.SaveImage()方法怎么样?

#2


17  

You can use the code below by passing proper ChartImageFormat.*:

您可以通过传递正确的ChartImageFormat来使用下面的代码。*:

this.chart1.SaveImage("C:\\mycode\\mychart.png", ChartImageFormat.Png);

Also look this SO if you met any problem: Save Image Using .net Chart and Saving higher resolution charts without messing up the appearance

如果您遇到任何问题,请查看此消息:使用.net图表保存图像并保存更高分辨率的图表而不会弄乱外观