Click here to Skip to main content
16,021,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.=)
Posted
Updated 22-Jul-12 18:35pm
v2

1 solution

Assuming you are using the Microsoft .NET charting component, you may use this code:
C#
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);
}
 
Share this answer
 
v2
Comments
Esmond90 23-Jul-12 0:33am    
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.=)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900