The RichEdit Control implements System.IServiceProvider and System.ComponentModel.Design.IServiceContainer interfaces. In addition to providing services, it also provides a mechanism for adding and removing services. To obtain a service, call the GetService method.
The following code replaces the DevExpress.XtraRichEdit.Services.IRichEditCommandFactoryService service with its customized descendant.
RichEditControlActions.cs |
richEditControl.Text = "A message box is displayed after saving a document using the 'Save' or 'Save As' button click since custom commands.";
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl, richEditControl.GetService<IRichEditCommandFactoryService>());
richEditControl.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
|
RichEditControlActions.vb |
richEditControl.Text = "A message box is displayed when a document is saved on the 'Save' or 'Save As' button click since custom commands are used"
Dim commandFactory = New CustomRichEditCommandFactoryService(richEditControl, richEditControl.GetService(Of IRichEditCommandFactoryService)())
richEditControl.ReplaceService(Of IRichEditCommandFactoryService)(commandFactory)
|

Example
The following code replaces the DevExpress.XtraRichEdit.Services.IRichEditCommandFactoryService service with its customized descendant.
RichEditControlActions.cs |
richEditControl.Text = "A message box is displayed after saving a document using the 'Save' or 'Save As' button click since custom commands.";
var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl, richEditControl.GetService<IRichEditCommandFactoryService>());
richEditControl.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
|
RichEditControlActions.vb |
richEditControl.Text = "A message box is displayed when a document is saved on the 'Save' or 'Save As' button click since custom commands are used"
Dim commandFactory = New CustomRichEditCommandFactoryService(richEditControl, richEditControl.GetService(Of IRichEditCommandFactoryService)())
richEditControl.ReplaceService(Of IRichEditCommandFactoryService)(commandFactory)
|