Back to Devexpress

RichEditControl.RemoveService(Type) Method

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-dot-removeservice-x28-system-dot-type-x29.md

latest8.0 KB
Original Source

RichEditControl.RemoveService(Type) Method

Removes the service of specified type from the service container.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public void RemoveService(
    Type serviceType
)
vb
Public Sub RemoveService(
    serviceType As Type
)

Parameters

NameTypeDescription
serviceTypeType

The type of service to remove.

|

Remarks

The RichEdit Control implements IServiceProvider and IServiceContainer interfaces. In addition to providing services, it also provides a mechanism for adding and removing services. To obtain a service, call the RichEditControl.GetService method.

The following code replaces the IRichEditCommandFactoryService service with its customized descendant.

View Example

csharp
var builtInService = richEditControl1.GetService<IRichEditCommandFactoryService>();
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl1,builtInService);
richEditControl1.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
vb
Dim builtInService = richEditControl1.GetService(Of IRichEditCommandFactoryService)()
Dim myCommandFactory = New CustomRichEditCommandFactoryService(richEditControl1,builtInService)
richEditControl1.ReplaceService(Of IRichEditCommandFactoryService)(myCommandFactory)

Example

The following code replaces the IRichEditCommandFactoryService service with its customized descendant.

View Example

csharp
var builtInService = richEditControl1.GetService<IRichEditCommandFactoryService>();
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl1,builtInService);
richEditControl1.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
vb
Dim builtInService = richEditControl1.GetService(Of IRichEditCommandFactoryService)()
Dim myCommandFactory = New CustomRichEditCommandFactoryService(richEditControl1,builtInService)
richEditControl1.ReplaceService(Of IRichEditCommandFactoryService)(myCommandFactory)

The following code snippets (auto-collected from DevExpress Examples) contain references to the RemoveService(Type) method.

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.

how-to-use-docvariable-fields/CS/DocumentVariablesExample/Form1.cs#L44

csharp
private void richEditControl1_MailMergeStarted(object sender, MailMergeStartedEventArgs e) {
    richEditControl1.RemoveService(typeof(IProgressIndicationService));
    richEditControl1.AddService(typeof(IProgressIndicationService),

winforms-richedit-copy-a-table-to-the-clipboard-in-the-unicode-text-format/CS/Form1.cs#L16

csharp
CustomRichEditCommandFactoryService commandFactory = new CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService<IRichEditCommandFactoryService>());
richEditControl1.RemoveService(typeof(IRichEditCommandFactoryService));
richEditControl1.AddService(typeof(IRichEditCommandFactoryService), commandFactory);

how-to-customize-copy-and-paste-commands/CS/RichEditCustomCopyPaste/Form1.cs#L15

csharp
CustomRichEditCommandFactoryService commandFactory = new CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService<IRichEditCommandFactoryService>());
richEditControl1.RemoveService(typeof(IRichEditCommandFactoryService));
richEditControl1.AddService(typeof(IRichEditCommandFactoryService), commandFactory);

how-to-use-docvariable-fields/VB/DocumentVariablesExample/Form1.vb#L45

vb
Private Sub richEditControl1_MailMergeStarted(ByVal sender As Object, ByVal e As MailMergeStartedEventArgs)
    richEditControl1.RemoveService(GetType(IProgressIndicationService))
    richEditControl1.AddService(GetType(IProgressIndicationService), New MyProgressIndicatorService(richEditControl1, progressBarControl1))

winforms-richedit-copy-a-table-to-the-clipboard-in-the-unicode-text-format/VB/Form1.vb#L17

vb
Dim commandFactory As New CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService(Of IRichEditCommandFactoryService)())
richEditControl1.RemoveService(GetType(IRichEditCommandFactoryService))
richEditControl1.AddService(GetType(IRichEditCommandFactoryService), commandFactory)

how-to-customize-copy-and-paste-commands/VB/Form1.vb#L25

vb
Dim commandFactory As New CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService(Of IRichEditCommandFactoryService)())
richEditControl1.RemoveService(GetType(IRichEditCommandFactoryService))
richEditControl1.AddService(GetType(IRichEditCommandFactoryService), commandFactory)

See Also

GetService(Type)

RichEditControl Services

ReplaceService<T>(T)

How to: Replace a Built-In Command with a Custom Command in Rich Text Editor for WinForms

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace