Nevron .NET Vision
Chart for .NET / User's Guide / Printing / Printing a Chart

In This Topic
    Printing a Chart
    In This Topic
     Calling the Print Method

    You can print the chart displayed by the control by calling the Print method of the NPrintManager object:

    C#
    Copy Code
    NPrintManager printManager = new NPrintManager(chartControl.Document);
    printManager.Print();
    
    Visual Basic
    Copy Code
    Dim printManager As New NPrintManager(chartControl.Document)
    printManager.Print()
    

    This will print the chart on the default printer with default page settings.

     Showing the Print Dialog

    Alternatively you can display the standard .NET print dialog allowing the user to select the printer and page settings:

    C#
    Copy Code
    NPrintManager printManager = new NPrintManager(chartControl.Document);
    printManager.ShowPrintDialog();
    
    Visual Basic
    Copy Code
    Dim printManager As New NPrintManager(chartControl.Document)
    printManager.ShowPrintDialog()
    
     Showing the Page Setup Dialog

    To show the standard .NET page setup dialog you must use the following code:

    C#
    Copy Code
    NPrintManager printManager = new NPrintManager(chartControl.Document);
    printManager.ShowPageSetupDialog();
    
    Visual Basic
    Copy Code
    Dim printManager As New NPrintManager(chartControl.Document)
    printManager.ShowPageSetupDialog()
    
     Showing the Print Preview Dialog

    To show a print preview of the current chart that also allows the user to print the chart you should use:

    C#
    Copy Code
    NPrintManager printManager = new NPrintManager(chartControl.Document);
    chartControl.PrintManager.ShowPrintPreview();
    
    Visual Basic
    Copy Code
    Dim printManager As New NPrintManager(chartControl.Document)                    
    printManager.ShowPrintPreview()
    
     Programmatically Controlling the Printer and Page Settings

    You may also programmatically control all settings related to printing by touching the PageSettings and PrinterSettings properties of the NPrintManager object. The following code will increase the margins to 2 inches (by default they are 1 inch):

    C#
    Copy Code
    NPrintManager printManager = new NPrintManager(chartControl.Document);                  
    printManager.PageSettings.Margins = new Margins(200, 200, 200, 200);
    printManager.Print();
    
    Visual Basic
    Copy Code
    Dim printManager As New NPrintManager(chartControl.Document)          
    printManager.PageSettings.Margins = New Margins(200, 200, 200, 200)
    printManager.Print()
    

    Note that the margins are specified in hundreds of an inch.

     Related Examples

    Windows Forms: Printing\Printing

    Windows Forms: Printing\Page Settings

    See Also