ICommandHandler.CanHandleCommand(ReportCommand, ref Boolean) Method
Indicates whether the specified End-User Designer command can be handled.
Namespace: DevExpress.XtraReports.UserDesigner
Assembly: DevExpress.XtraReports.v25.1.Extensions.dll
NuGet Package: DevExpress.Win.Reporting
Declaration
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
trueand theuseNextHandlerparameter isfalse, the ICommandHandler.HandleCommand method is called; this method then runs only the custom handler for the specified command.When CanHandleCommand returns
falseand theuseNextHandlerparameter istrue, the next handler from the list will be executed, which will returntruefor CanHandleCommand.When CanHandleCommand returns
trueand theuseNextHandlerparameter istrue, the ICommandHandler.HandleCommand method is called for each handler in the list that returnstruefor CanHandleCommand.When CanHandleCommand returns
falseand theuseNextHandlerparameter isfalse, 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;
}