Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Scheduler (new)
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charting
    Printing
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Services

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 Scheduler 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 simply 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 SpreadsheetControl.ReplaceService<T> method.

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.

How would you rate this topic?​​​​​​​