views:

157

answers:

1

I'm using Dundas Chart Profession within my VB program to generate a chart based on my data. Right now I have my charts opening fine but I am unsure how to add the functionality to let the user choose to print (and export) the chart once the program is running.

A: 

I didn't figure out how to export the chart but I have figured out how to print and save it.

To print:

To print the chart I found the solution here. This is on the Dundas Data Visualization Components Support page labeled under "Customizing the size of printed chart". Also in case you are wondering how they got the PrintDocument, like me, it is located under System.Drawing.Printing.PrintDocument.

To save:

To save all you have to have is

ChartName.SaveAsImage("pathwayAndFileName.png", ChartImageFormat.Png)

Where ChartImageFormat is under Dundas.Charting.WinControl and png can be any extension under Dundas.Charting.WinControl.ChartImageFormat. Of course this ran into having to know the filename and pathway that the user wants to use so I researched how to do the dialog for saving, built in, as I didn't want to recreate it myself. I found the SaveFiledialog under System.Windows.Forms where they also have open, load, and print. Of course I already had the other print.

To set the initial directory it uses is

dialogName.InitialDirectory = Application.StartupPath

Then open it with ShowDialog

Kyra