ICommandHandler.CanHandleCommand(ReportCommand, ref Boolean) Method

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

Namespace: DevExpress.XtraReports.UserDesigner

Assembly: DevExpress.XtraReports.v21.1.Extensions.dll


bool CanHandleCommand(
    ReportCommand command,
    ref bool useNextHandler


Name Type Description
command ReportCommand

A ReportCommand enumeration value that specifies the command.

useNextHandler Boolean

true to allow calling the next handler registered for this command; otherwise false.


Type Description

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


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, as well as to control which handlers to invoke.

When useNextHandler is disabled, the next handler (the default one, in the following example) is not invoked. And, because useNextHandler is always set to false (False in Visual Basic), with no regard to the command in question, this means that the default handler will not be invoked for any command.

The following code illustrates this behavior: the Delete command will always be handled, with no regard to the conditions specified in the ICommandHandler.HandleCommand method body. As a result, you are not permitted to delete report bands, for example.

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

In turn, the ICommandHandler.HandleCommand method is called only when the CanHandleCommand method returns true (True in Visual Basic), which means that all logical conditions should be evaluated with the CanHandleCommand method body.

See Also