The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ISpreadsheetCommandFactoryService Interface

A service which is used to create Spreadsheet commands.

Namespace: DevExpress.XtraSpreadsheet.Services

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

[ComVisible(true)]
public interface ISpreadsheetCommandFactoryService
<ComVisible(True)>
Public Interface ISpreadsheetCommandFactoryService
[ComVisible(true)]
public interface ISpreadsheetCommandFactoryService
<ComVisible(True)>
Public Interface ISpreadsheetCommandFactoryService

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.

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);
    }

}
See Also