如何使用savefiledialog将图表保存为图像? [英] how to save a chart graph as image using savefiledialog?

查看:84
本文介绍了如何使用savefiledialog将图表保存为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi ..如何使用savefiledialog将图表图形另存为图像?我已经得到一个图表,并且我想单击菜单栏中的另存为"以将图形另存为.jpeg,.bitmap和.gif文件.我在窗体上创建菜单条,然后在其上创建将图形另存为.."功能.然后,当我单击它时,将弹出一个窗口,询问哪种文件类型(.jpeg,.bitmap). ,.gif)以及要保存的文件名.但是该图是用户控件.我该怎么做?您能提供一些代码供我参考吗?谢谢)=)

hi..how to save a chart graph as image using savefiledialog?i already get a graph,and i want to click save graph as in the menu bar to save the graph as .jpeg,.bitmap and .gif file..I create a menu stript on the Form and I want to create a function of "save graph as.." on it.Then when I click it, a window will pop up to ask which type of file(.jpeg,.bitmap,.gif) and what filename to be saved.But the graph is a user control.how can I do it?Would you provide me some code for reference?Thanks.=)

推荐答案

假定您正在使用Microsoft .NET图表组件,则可以使用以下代码:
Assuming you are using the Microsoft .NET charting component, you may use this code:
private void button1_Click(object sender, EventArgs e)
{
  SaveFileDialog dlg = new SaveFileDialog();
  if(dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    this.chart1.SaveImage(dlg.FileName, ChartImageFormat.Png);
}


这篇关于如何使用savefiledialog将图表保存为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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