Skip to main content
.NET 6.0+

IRichTextValueStorage Interface

Declares members of the Rich Text editor’s value storage.

Namespace: DevExpress.ExpressApp.Office.Win

Assembly: DevExpress.ExpressApp.Office.Win.v24.1.dll

Declaration

public interface IRichTextValueStorage

Remarks

A Rich Text editor’s value storage allows you to implement custom logic executed when saving or loading a RichText document. Follow the steps below to create a custom value storage that overrides a file storage format.

  1. Create a class that implements the IRichTextValueStorage interface as shown below in the WinForms module project (MySolution.Module.Win). If your solution does not contain this project, add the Controller to the WinForms application project (MySolution.Win).

    using DevExpress.ExpressApp.Office.Win;
    using DevExpress.XtraRichEdit;
    //..
    public class MhtRichTextValueStorage : IRichTextValueStorage {
        public object GetValue(RichEditControl control) {
            return control.MhtText;
        }
        public void SetValue(RichEditControl control, object propertyValue) {
            control.MhtText = (string)propertyValue;
        }
    }
    
  2. Create a View Controller and access the RichTextPropertyEditor as described in the Ways to Access UI Elements and Their Controls topic. Set the editor’s ValueStorage property to an instance of CustomRichTextValueStorage as shown below:

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Office.Win;
    // ...
    public class RichTextValueStorageController : ObjectViewController<DetailView, Document> {
        protected override void OnActivated() {
            base.OnActivated();
            RichTextPropertyEditor richTextPropertyEditor = View.FindItem("Text") as RichTextPropertyEditor;
            if (richTextPropertyEditor != null) {
                richTextPropertyEditor.ValueStorage = new MhtRichTextValueStorage();
            }
        }
    }
    
See Also