windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-dot-removeservice-x28-system-dot-type-x29.md
Removes the service of specified type from the service container.
Namespace : DevExpress.XtraRichEdit
Assembly : DevExpress.XtraRichEdit.v25.2.dll
NuGet Package : DevExpress.Win.RichEdit
public void RemoveService(
Type serviceType
)
Public Sub RemoveService(
serviceType As Type
)
| Name | Type | Description |
|---|---|---|
| serviceType | Type |
The type of service to remove.
|
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.
var builtInService = richEditControl1.GetService<IRichEditCommandFactoryService>();
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl1,builtInService);
richEditControl1.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
Dim builtInService = richEditControl1.GetService(Of IRichEditCommandFactoryService)()
Dim myCommandFactory = New CustomRichEditCommandFactoryService(richEditControl1,builtInService)
richEditControl1.ReplaceService(Of IRichEditCommandFactoryService)(myCommandFactory)
The following code replaces the IRichEditCommandFactoryService service with its customized descendant.
var builtInService = richEditControl1.GetService<IRichEditCommandFactoryService>();
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl1,builtInService);
richEditControl1.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
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
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
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
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
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
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
Dim commandFactory As New CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService(Of IRichEditCommandFactoryService)())
richEditControl1.RemoveService(GetType(IRichEditCommandFactoryService))
richEditControl1.AddService(GetType(IRichEditCommandFactoryService), commandFactory)
See Also
How to: Replace a Built-In Command with a Custom Command in Rich Text Editor for WinForms