expressappframework-400004-document-management-office-module-use-rich-text-documents-in-business-objects.md
This topic describes how to use the DevExpress.ExpressApp.Office.Win.RichTextPropertyEditor and DevExpress.ExpressApp.Office.Blazor.Editors.RichTextPropertyEditor for byte array and string properties in WinForms and for ASP.NET Core Blazor applications. The following images demonstrate these Property Editors assigned to the Document.Text property:
Windows Forms ASP.NET Core Blazor
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:
[EditorAlias(EditorAliases.RichTextPropertyEditor)]
public virtual byte[] Text { get; set; }
// String property example:
[FieldSize(FieldSizeAttribute.Unlimited)]
[EditorAlias(EditorAliases.RichTextPropertyEditor)]
public virtual string Text { get; set; }
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
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); }
}
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 or DevExpress.ExpressApp.Office.Blazor.Editors.RichTextPropertyEditor.
In ASP.NET Core Blazor applications, your application saves the documents in the DOCX format when you use the Rich Text Property Editors for a byte array property. The RTF format is used for string properties. Alternatively, you can 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.
In WinForms applications, you can open the document in a new modal window using the Show in popup context menu command.
See Also