liumang 发表于 2012-12-18 18:56:32

Devexpress RichEditControl控件——笔记

<div id="cnblogs_post_body">环境: win7, winform ,vs2012 ,deve 12.1.5
项目中需要用富文本控件来编辑文档(包括floating格式的图片),然后需要在网页中显示,并且在word中打印。

下面是我的解决方案。 (请注意devexpress版本为12.1.5,我在搜资料的时候看到11的版本好像也可以,但是我自己没有试过,这个请自行考虑)
1:关于floating格式的图片,网上中文资料不多,英文的很多,可以自己去搜。 下面是我搜到的代码.

<div class="cnblogs_code">//自定义用户插入floating图片的辅助类
public class CustomInsertFloatingObjectPictureCoreCommand : InsertFloatingObjectPictureCoreCommand
    {
      Image _IMG = null;
      public CustomInsertFloatingObjectPictureCoreCommand(IRichEditControl control,Image img)
            : base(control)
      {
            this._IMG = img;
      }
      protected override DevExpress.XtraRichEdit.Model.FloatingObjectContent CreateDefaultFloatingObjectContent(DevExpress.XtraRichEdit.Model.FloatingObjectAnchorRun run)
      {
            return new PictureFloatingObjectContent(run, RichEditImage.CreateImage(_IMG));
      }
      protected override void ModifyModel()
      {
            this.ImportSource = new DevExpress.Office.Internal.ImportSource<RichEditImageFormat, RichEditImage>("", new BitmapPictureImporter());
            base.ModifyModel();
      }
    }


//代码中直接使用如下代码
CustomInsertFloatingObjectPictureCoreCommand cmd = new CustomInsertFloatingObjectPictureCoreCommand(richEditControl1, img);
页: [1]
查看完整版本: Devexpress RichEditControl控件——笔记