[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charts and Graphics
    Operation Restrictions
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Themes and Templates
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)


A service is a class with a known interface, addressable by its type. A service can be obtained from a service provider, instantiated and stored within a service container. The SpreadsheetControl implements the base interfaces contained within the System.ComponentModel namespace of .NET - the System.IServiceProvider and System.ComponentModel.Design.IServiceContainer. You can obtain a service for the SpreadsheetControl by using the SpreadsheetControl.GetService<T> method.

When you get a service via the GetService method, you actually use the specified interface to obtain a pointer to an object that implements the methods of this interface. You can save this pointer (and the object it references), and delete the service implementation from the SpreadsheetControl using the SpreadsheetControl.RemoveService method. When it is done, the corresponding GetService method will return null.

At that time, you can install your own service using the SpreadsheetControl.AddService method. Subsequent calls to GetService will return the pointer to an object representing your service. So, the calls to service methods are redirected from the default implementation to a custom one. It is done silently and transparently for the caller.

This mechanism enables you to modify the default behavior of an application that uses these services at any time, without re-designing it.

Instead of the utilizing the GetService -> RemoveService -> AddService method sequence, you can use the generic DevExpress.Xpf.Spreadsheet.SpreadsheetControl.ReplaceService``1 method. Note that due to WPF SpreadsheetControl implementation specifics, it is necessary to replace the built-in service after the control is initialized.

SpreadsheetControl implements the following services.

Service Description
ISpreadsheetCommandFactoryService A service which is used to create Spreadsheet commands.
IMessageBoxService A service that enables you to display a custom message box when a runtime error occurs.
IFormatDetectorService Allows detecting the format of a document contained in a stream.
ICustomCalculationService Allows managing the process of worksheet calculations.
IDefinedNameValidator A validator used to check whether a new version of the conflict defined name is valid and unique before pasting it into the destination document.
ICustomAssemblyLoadingNotificationService Enables determining whether a custom assembly containing the Entity Framework data model is allowed to load during Mail Merge.
IObjectDataSourceValidationService Allows custom validation of the DevExpress.DataAccess.ObjectBinding.ObjectDataSource data sources before using them in the document.

Expanded See Also

Is this topic helpful?​​​​​​​