EPR类企业管理系统

在我们现有系统基础上或全新开发,提供定制服务
为您的企业高效快速实施ERP,WMS,MES,CRM管理系统
全面管控物料仓库、销售业务、采购业务、仓库业务
生产过程、质量检验、组织架构、业务报表


定制
QQ:460-3528

开发
QQ群:3360-90194

源码
微信:136-3650-3721

如何:访问RTF编辑器控件

本主题描述如何使用Office模块访问和自定义XAF应用程序中的以下控件:

平台

控制

目的

WinForms

RichEditControl

用于显示RTF文档

ASP.NET

ASPxRichEdit

用于显示RTF文档

ASP.NET

ASPxUploadControl

用于在服务器上上传RTF文档

访问特定于WinForms的控件(RichEditControl)

请按照以下步骤访问RichEditControl并启用“拼写检查”功能

  1. 在WinForms模块项目中创建一个自定义ViewController
  2. DevExpress.SpellChecker.v 19.2 .dllDevExpress.XtraSpellChecker.v 19.2 .dll程序集添加到项目引用中
  3. 重写OnActivated方法并处理RichTextServiceController.CustomizeRichEditControl事件。在事件处理程序中,创建并设置SpellChecker对象,然后将此对象传递给SpellChecker属性。
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Win;
using DevExpress.XtraRichEdit;
using DevExpress.XtraSpellChecker;

public partial class WinRichEditController : ViewController {
// ...
    protected override void OnActivated() {
        base.OnActivated();
        RichTextServiceController controller = Frame.GetController<RichTextServiceController>();
        if(controller != null) {
            controller.CustomizeRichEditControl  = Controller_CustomizeRichEditControl;
        }
    }
    private void Controller_CustomizeRichEditControl(object sender, CustomizeRichEditEventArgs e) {
        SpellChecker spellChecker = new SpellChecker();
        spellChecker.SetSpellCheckerOptions(e.RichEditControl, new OptionsSpelling());
        spellChecker.SpellCheckMode = SpellCheckMode.AsYouType;
        e.RichEditControl.SpellChecker = spellChecker;
    }
}
注意

英文字典是拼写检查器的默认字典。请参阅“词典”主题以了解如何更改词典。

访问特定于ASP.NET的控件

访问ASPxRichEdit控件

请按照以下步骤访问ASPxRichEdit控件并启用“拼写检查”功能

  1. 在ASP.NET模块项目中创建一个自定义ViewController
  2. DevExpress.Web.ASPxSpellChecker.v 19.2 .dll程序集添加到项目引用中
  3. 重写OnActivated方法并处理ASPxRichTextPropertyEditor.ControlCreated事件。在事件处理程序中,创建并设置ASPxSpellCheckerOpenOfficeDictionary对象,然后将此对象添加到Dictionaries集合。将Enabled属性设置为true以启用拼写检查器组件。
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Web;
using DevExpress.Web.ASPxRichEdit;
using DevExpress.Web.ASPxSpellChecker;
using System;
using System.Globalization;
// ...
public class WebRichEditController : ViewController<DetailView> {
    protected override void OnActivated() {
        base.OnActivated();
        foreach(ASPxRichTextPropertyEditor editor in View.GetItems<ASPxRichTextPropertyEditor>()) {
            if(editor.ASPxRichEditControl != null) {
                CustomizeRichEditControl(editor.ASPxRichEditControl);
            } else {
                editor.ControlCreated  = Editor_ControlCreated;
            }
        }
    }
    private void Editor_ControlCreated(object sender, EventArgs e) {
        ASPxRichEdit richEdit = ((ASPxRichTextPropertyEditor)sender).ASPxRichEditControl;
        CustomizeRichEditControl(richEdit);
    }
    private void CustomizeRichEditControl(ASPxRichEdit richEdit) {
        ASPxSpellCheckerOpenOfficeDictionary dictionary = new ASPxSpellCheckerOpenOfficeDictionary();
        dictionary.GrammarPath = "~/App_Data/Dictionaries/en_US.aff";
        dictionary.DictionaryPath = "~/App_Data/Dictionaries/en_US.dic";
        dictionary.Culture = new CultureInfo("en-US");
        dictionary.CacheKey = "enDic";
        richEdit.Settings.SpellChecker.Dictionaries.Add(dictionary);
        richEdit.Settings.SpellChecker.Enabled = true;
        richEdit.Settings.SpellChecker.SuggestionCount = 4;
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        foreach(ASPxRichTextPropertyEditor editor in View.GetItems<ASPxRichTextPropertyEditor>()) {
            editor.ControlCreated -= Editor_ControlCreated;
        }
    }
}

访问ASPxUploadControl

请按照以下步骤访问ASPxUploadControl并设置要上传到服务器的文件的最大大小。

  1. 在ASP.NET模块项目中创建一个自定义ViewController
  2. 在重写的OnActivated方法中,处理ASPxSpreadsheetPropertyEditor.ControlCreated事件。
  3. 在事件处理程序中,使用MaxFileSize方法指定要上传到服务器的文件的最大大小。
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Web;
using DevExpress.Web;
using System;
// ...
public class WebRichEditUploadController : ViewController<DetailView> {
    protected override void OnActivated() {
        base.OnActivated();
        foreach (ASPxRichTextPropertyEditor editor in View.GetItems<ASPxRichTextPropertyEditor>()) {
            if (editor.ASPxUploadControl != null) {
                CustomizeRichEditUploadControl(editor.ASPxUploadControl);
            }
            else {
                editor.ControlCreated  = Editor_ControlCreated;
            }
        }
    }
    private void Editor_ControlCreated(object sender, EventArgs e) {
        ASPxUploadControl richEditUploadControl = ((ASPxRichTextPropertyEditor)sender).ASPxUploadControl;
        CustomizeRichEditUploadControl(richEditUploadControl);
    }
    private void CustomizeRichEditUploadControl(ASPxUploadControl uploadControl) {
        uploadControl.ValidationSettings.MaxFileSize = 104857600;
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        foreach (ASPxRichTextPropertyEditor editor in View.GetItems<ASPxRichTextPropertyEditor>()) {
            editor.ControlCreated -= Editor_ControlCreated;
        }
    }
}
相关文章

转载保留此链接,注明出处