Skip to main content

ICommandHandler.CanHandleCommand(ReportCommand, ref Boolean) Method

Indicates whether the specified End-User Designer command can be handled.

Namespace: DevExpress.XtraReports.UserDesigner

Assembly: DevExpress.XtraReports.v23.2.Extensions.dll

NuGet Package: DevExpress.Win.Reporting

Declaration

bool CanHandleCommand(
    ReportCommand command,
    ref bool useNextHandler
)

Parameters

Name Type Description
command ReportCommand

A ReportCommand enumeration value that specifies the command.

useNextHandler Boolean

true - allows a call to the next handler registered for this command; otherwise, false.

Returns

Type Description
Boolean

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

Remarks

First, the Report Designer executes custom handlers (the objects that implement ICommandHandler, then it executes default designer handlers for the specified command.

The useNextHandler parameter determines whether or not to invoke the next handler for the current command. This allows you to define multiple command handlers for a single command and to control which handlers to invoke.

  • When CanHandleCommand returns true and the useNextHandler parameter is false, the ICommandHandler.HandleCommand method is called; this method then runs only the custom handler for the specified command.

  • When CanHandleCommand returns false and the useNextHandler parameter is true, the next handler from the list will be executed, which will return true for CanHandleCommand.

  • When CanHandleCommand returns true and the useNextHandler parameter is true, the ICommandHandler.HandleCommand method is called for each handler in the list that returns true for CanHandleCommand.

  • When CanHandleCommand returns false and the useNextHandler parameter is false, neither the custom implementation nor the default implementation of the specified command is run.

The following code snippet shows an implementation of CanHandleCommand that allows the user to run a custom implementation of the Delete command:

public bool CanHandleCommand(ReportCommand command, ref bool useNextHandler) {
    useNextHandler = command != ReportCommand.Delete;
    return command == ReportCommand.Delete;
}
See Also