Search code examples
c#chartsmschart

Set printing settings programmatically for chart control (mscharts)


Is there a way to programmatically set some of the settings for the chart printing? I want the default print orientation to be landscape, but the only way I can find to do that is launch the chart1.Printing.PageSetup() and have the user do it. I'd prefer to handle it all myself in code.

Below are my options. I tried playing with the PrintDocument settings, but couldn't find what I needed.

Options

I'm using Visual Studio 2010 and .NET 4.0 and I'm using winforms.


Solution

  • You can set all kinds of properties, pretty much as you tried to do. Just look a little closer into the various properties of the PrintDocument, which is a regular PrintDocument object!

    The Orientation is hidden behind the Landscape property..:

     chart1.Printing.PrintDocument.DefaultPageSettings.Landscape = true;