expressappframework-400063-document-management-office-module-access-rich-text-editor-controls.md
This topic describes how to access and customize the following controls in XAF applications with the Office Module:
|
Platform
|
Control
|
Purpose
| | --- | --- | --- | |
ASP.NET Core Blazor
|
|
Displays Rich Text documents
| |
WinForms
|
|
Displays Rich Text documents
|
This topic describes the following tasks:
Follow these steps to access the DxRichEditModel component model. A component model defines a Blazor component in code. When you modify the model, the underlying component reflects these changes. For more information about component models, refer to the following topic: Underlying Controls and Components Behind UI Elements (ASP.NET Core Blazor).
OnActivated method, use the CustomizeViewItemControl<T>(DetailView, Controller, Action<T>) extension method to customize the RichTextPropertyEditor.DevExpress.ExpressApp.Office.Blazor.Components.Models.DxRichEditModel component model and do the following:OnActivated method and use the CustomizeViewItemControl<T>(DetailView, Controller, Action<T>) extension method. Create and set up the SpellChecker object and pass this object to the SpellChecker property.Note
The spell checker uses an English dictionary by default. To see how to change the dictionary, refer to the following topic: Dictionaries.
The RichTextPropertyEditor menu does not display all available toolbars and ribbon tabs. Use the static RichTextPropertyEditor.DefaultRichEditToolbarType property to customize toolbars. The available toolbars and tabs are listed in the RichEditToolbarType enumeration.
using DevExpress.XtraRichEdit;
using DevExpress.ExpressApp.Office.Win;
// ...
RichTextPropertyEditor.DefaultRichEditToolbarType =
RichEditToolbarType.Home | RichEditToolbarType.Insert | RichEditToolbarType.File |
RichEditToolbarType.FloatingObject | RichEditToolbarType.Table | RichEditToolbarType.HeaderFooter;
Handle the MenuManagerController.CustomizeRichEditToolbarType event to change toolbar and tab availability for a single editor:
MenuManagerController and subscribe to its CustomizeRichEditToolbarType event in the overridden OnActivated method.CustomizeRichEditToolbarTypeEventArgs.RichEditToolbarType property.You can also use the Toolbar Customization menu at runtime. The result is saved to the user’s model differences.
Handle the CustomizeRibbonControl event to customize the ribbon. Use the event argument’s RibbonControl property to access ribbon settings.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Win;
using DevExpress.XtraRichEdit;
namespace YourSolutionName.Win.Controllers;
public class CustomRichEditController : ViewController {
protected override void OnActivated() {
base.OnActivated();
MenuManagerController controller = Frame.GetController<MenuManagerController>();
if (controller != null) {
controller.CustomizeRibbonControl += Controller_CustomizeRibbonControl;
}
}
private void Controller_CustomizeRibbonControl(object sender, CustomizeRibbonControlEventArgs e) {
BarButtonItem customButton = e.RibbonControl.Items.CreateButton("Test");
MenuManagerController menuManagerController = (MenuManagerController)sender;
var defaultCategory = menuManagerController.RibbonObjectsContainer.RichRibbonCategories.FirstOrDefault(t => t.Text == "RichText");
defaultCategory.Pages[0].Groups[0].ItemLinks.Add(customButton);
}
}
This section demonstrates how to use the Model Editor to customize the Rich Text Property Editor in a Windows Forms project.
The RichTextPropertyEditor menu manager can display a Ribbon Control or Bars.
Navigate to the Views | <DetailView> | Items | <PropertyEditor> node and set the editor’s MenuManagerType:
Set the BOModel | <Class> | OwnMembers | <Member> node’s DocumentStorageFormat property to the desired format (RTF or HTML) for string properties.
You can use a byte array property to save documents in the DOCX format or a string property to store documents in the RTF and HTML formats.
In WinForms applications, the Rich Text Editor’s height is fixed and equal to the height of a single-line editor.
To change the editor’s height, set the IModelRichTextColumn.CustomHeight property in the Views | <ListView> | Columns | <Column> node.
Set the CustomHeight property to -1 to allow the grid control to automatically calculate the row height based on the Rich Text Editor’s content in WinForms.