ICommandHandler.CanHandleCommand(ReportCommand, ref Boolean) Method
Indicates whether the specified End-User Designer command can be handled.
Namespace: DevExpress.XtraReports.UserDesigner
Assembly: DevExpress.XtraReports.v24.2.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
true
and theuseNextHandler
parameter isfalse
, the ICommandHandler.HandleCommand method is called; this method then runs only the custom handler for the specified command.When CanHandleCommand returns
false
and theuseNextHandler
parameter istrue
, the next handler from the list will be executed, which will returntrue
for CanHandleCommand.When CanHandleCommand returns
true
and theuseNextHandler
parameter istrue
, the ICommandHandler.HandleCommand method is called for each handler in the list that returnstrue
for CanHandleCommand.When CanHandleCommand returns
false
and theuseNextHandler
parameter 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;
}