Use Rich Text Documents in Business Objects

  • 2 min to read

This topic describes how to use the RichTextPropertyEditor and ASPxRichTextPropertyEditor for byte array and string properties in WinForms and ASP.NET 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 RichTextPropertyEditor or ASPxRichTextPropertyEditor 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;
// ...
// Byte array property example:
private byte[] text;
[EditorAlias(EditorAliases.RichTextPropertyEditor)] 
public byte[] Text { 
    get { return text; }
    set { SetPropertyValue(nameof(Text), ref text, value); }
}

// String property example:
private string text;
[Size(SizeAttribute.Unlimited)]
[EditorAlias(EditorAliases.RichTextPropertyEditor)] 
public string Text { 
    get { return text; }
    set { SetPropertyValue(nameof(Text), ref text, value); }
}

In the Model Editor

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

Document Storage Formats

When you use the RichTextPropertyEditor or ASPxRichTextPropertyEditor 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 applications, you can edit the document in full-screen mode.

See Also