ISpreadsheetCommandFactoryService Interface
A service which is used to create Spreadsheet commands.
Namespace: DevExpress.XtraSpreadsheet.Services
Assembly: DevExpress.Spreadsheet.v19.1.Core.dll
Declaration
Remarks
All commands in the SpreadsheetControl are created using the command factory service. You can substitute the default command factory service with its descendant, designed to create a custom command instead of the default command. Subsequently, the specified custom command is used in all SpreadsheetControl operations instead of the original command.
To substitute a default command factory service, create a class descending from the SpreadsheetCommandFactoryServiceWrapper class. Do not implement the ISpreadsheetCommandFactoryService interface directly in your class.
The following code snippet demonstrates a custom service used to substitute for the Clear Contents formatting commands located in Ribbon and context menu with a custom command.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-replace-standard-spreadsheetcontrol-command-with-your-own-custom-command-t163272
public class CustomService : SpreadsheetCommandFactoryServiceWrapper {
public CustomService(ISpreadsheetCommandFactoryService service)
: base(service) {
}
public SpreadsheetControl Control {get;set;}
public override SpreadsheetCommand CreateCommand(SpreadsheetCommandId id)
{
if (id == SpreadsheetCommandId.FormatClearContents || id == SpreadsheetCommandId.FormatClearContentsContextMenuItem)
return new CustomFormatClearContentsCommand(Control);
return base.CreateCommand(id);
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ISpreadsheetCommandFactoryService interface.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.