ICommandHandler.CanHandleCommand(PrintingSystemCommand, IPrintControl) Method

Indicates whether or not the specified Printing System command can be handled.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v20.2.Core.dll


bool CanHandleCommand(
    PrintingSystemCommand command,
    IPrintControl printControl
Function CanHandleCommand(
    command As PrintingSystemCommand,
    printControl As IPrintControl
) As Boolean


Name Type Description
command PrintingSystemCommand

A PrintingSystemCommand enumeration value.

printControl IPrintControl

An object implementing the IPrintControl interface (typically, this is a PrintControl instance).


Type Description

true, if the command can be handled; otherwise, false.


This example illustrates how to override a Printing System command.

A custom command handler must implement the ICommandHandler interface. You can add it to a Printing System's list of handlers using the PrintingSystemBase.AddCommandHandler method.

using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    // Create a Print Tool with an assigned report instance.
    ReportPrintTool printTool = new ReportPrintTool(new XtraReport1());

    // Generate the report's document to be able to access its Printing System.

    // Override the ExportGraphic command.
    printTool.PrintingSystem.AddCommandHandler(new ExportToImageCommandHandler());

    // Show the report's Print Preview in a dialog window.


public class ExportToImageCommandHandler : ICommandHandler {
    public virtual void HandleCommand(PrintingSystemCommand command,
    object[] args, IPrintControl printControl, ref bool handled) {
        if (!CanHandleCommand(command, printControl)) return;

        // Export the document to PNG.
        printControl.PrintingSystem.ExportToImage("C:\\Report.png", System.Drawing.Imaging.ImageFormat.Png);

        // Prevent the default exporting procedure from being called.
        handled = true;

    public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl) {
        return command == PrintingSystemCommand.ExportGraphic;
See Also