Skip to main content
A newer version of this page is available. .

Use Rich Text Documents in Business Objects

  • 3 minutes to read

This topic describes how to customize the RichTextPropertyEditor‘s behavior and use the editor for byte array and string properties. The following image demonstrates this property editor assigned to the Document.Text property:

Document Storage Formats

When you use the RichTextPropertyEditor for a byte array property, your application saves the documents in the DOCX format. The RTF format is used for the string properties (you can optionally change the format to HTML). We recommend using byte arrays instead of strings to store your documents because the DOCX format works faster with large documents and supports more formatting options.

Enable the RichTextPropertyEditor in Code

To enable the RichTextPropertyEditor for a business class’ property, apply the EditorAliasAttribute to this property as follows:

// Byte array property example:
[EditorAlias(EditorAliases.RichTextPropertyEditor)] 
public byte[] Text { get; set; }

// String property example:
[Size(SizeAttribute.Unlimited)]
[EditorAlias(EditorAliases.RichTextPropertyEditor)] 
public string TextString { get; set; }

Enable the RichTextPropertyEditor and Customize its Behavior in the Model Editor

You can use the Model Editor in a WinForms application project to enable the RichTextPropertyEditor and perform the additional customizations described below.

Use RichTextPropertyEditor in a Specific Detail View

Navigate to the required Views | <DetailView> | Items | <PropertyEditor> node and set the PropertyEditorType property to DevExpress.ExpressApp.Office.Win.RichTextPropertyEditor.

Use the Ribbon or Bars Menu

The RichEditPropertyEditor is created with the menu manager containing the Ribbon Control or Bars. You can specify the editor’s MenuManagerType in the Views | <DetailView> | Items | <PropertyEditor> node.

Change the Document Storage Format

For string properties, you can choose the document storage format (RTF or HTML) using the BOModel | <Class> | OwnMembers | <Member> node’s DocumentStorageFormat property.

The format is always DOCX for byte array properties.

Specify the Column Height in a List View

Use the Views | <ListView> | Columns | <Column> node’s CustomHeight property to change the editor’s height if you are using the RichEditPropertyEditor in a ListView Column.

Edit the Document in a Separate Window

You can open the document in a new modal window using the Show in popup context menu command.

Customize the Menu

The RichEditPropertyEditor‘s menu does not display all the available toolbars and ribbon tabs by default. You can use the static RichEditPropertyEditor.DefaultRichEditToolbarType property to customize the toolbars. The available toolbars 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 the toolbars for a specific editor only.

You can customize the Bars menu at runtime. The result is saved to the user’s model differences.