I found this similar question, which I tried to implement, but it didn’t work.
I have a class that creates a chart and has a second constructor if someone wants to save the chart as an image. However, the images that are being saved are just of the form background, not the chart. Here is my code.
public ChartForm(String path)
{
InitializeComponent();
SaveGraphAsImage(path);
}
private void SaveChartAsImage(String path)
{
bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width, this.Height));
this.bmp.Save(path + this.Name, System.Drawing.Imaging.ImageFormat.Jpeg);
}
I fixed the problem by saving the image of the chart after the chart was populated with data.