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.
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()
|
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()
|
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()
|
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.
Windows Forms: Printing\Printing
Windows Forms: Printing\Page Settings