Back to Devexpress

How to: Execute Commands in the Print Preview

windowsforms-2422-controls-and-libraries-printing-exporting-examples-print-preview-how-to-execute-commands-in-the-print-preview.md

latest1.8 KB
Original Source

How to: Execute Commands in the Print Preview

  • Nov 13, 2018

This example illustrates how to execute commands corresponding to various end-user actions in Print Preview by using the PrintControl.ExecCommand method of the DocumentViewer control.

Some of these commands are called without any parameters, while others require calling an overloaded version of the PrintControl.ExecCommand method accepting custom parameter values.

csharp
using DevExpress.XtraPrinting;
// ...

// Zoom a document to fit the entire page into Print Preview dimensions.
documentViewer1.ExecCommand(PrintingSystemCommand.ViewWholePage);

// Invoke the Hand tool.
documentViewer1.ExecCommand(PrintingSystemCommand.HandTool, new object[] {true}); 

// Hide the Hand tool.
documentViewer1.ExecCommand(PrintingSystemCommand.HandTool, new object[] {false});
vb
Imports DevExpress.XtraPrinting
' ...

' Zoom a document to fit the entire page into Print Preview dimensions.
documentViewer1.ExecCommand(PrintingSystemCommand.ViewWholePage)

' Invoke the Hand tool.
documentViewer1.ExecCommand(PrintingSystemCommand.HandTool, New Object() {True})

' Hide the Hand tool.
documentViewer1.ExecCommand(PrintingSystemCommand.HandTool, New Object() {False})

See Also

How to: Change The Visibility of Toolbar Buttons and Menu Items in the Print Preview