Skip to main content

Use Rich Text Documents in Business Objects

  • 3 minutes to read

This topic describes how to use the DevExpress.ExpressApp.Office.Win.RichTextPropertyEditor, DevExpress.ExpressApp.Office.Web.ASPxRichTextPropertyEditor, and DevExpress.ExpressApp.Office.Blazor.Editors.RichTextPropertyEditor for byte array and string properties in WinForms, ASP.NET Web Forms and for ASP.NET Core Blazor applications. The following images demonstrate these Property Editors assigned to the Document.Text property:

Assign the Rich Text Property Editor to a Business Class’ Property

In Code

To enable the Rich Text Property Editors for a business class’ property, apply the EditorAliasAttribute to this property as follows:

using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
// ...
// Byte array property example:
public virtual byte[] Text { get; set; }

// String property example:
public virtual string Text { get; set; }

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

In the Model Editor

Open Model Differences in the platform-specific project. Navigate to the required Views | <DetailView> | Items | <PropertyEditor> node and set the PropertyEditorType property to DevExpress.ExpressApp.Office.Win.RichTextPropertyEditor, DevExpress.ExpressApp.Office.Web.ASPxRichTextPropertyEditor, or DevExpress.ExpressApp.Office.Blazor.Editors.RichTextPropertyEditor.

Document Storage Formats

In ASP.NET Web Forms and ASP.NET Core Blazor applications, when you use the Rich Text Property Editors for a byte array property, your application saves the documents in the DOCX format. The RTF format is used for string properties. Note that you can also 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.

Edit the Document in a Separate Window

In WinForms applications, you can open the document in a new modal window using the Show in popup context menu command.

In ASP.NET Web Forms applications, you can edit the document in full-screen mode.

See Also