01]生成Ribbon工具栏
02]添加 打印预览
03]添加新 按钮
030添加绑定自带事件
031用代码 添加新文本
032用代码 添加新文本框
04]显示行号
05]拼写检查,支持英文,不支持中文.只支持 空格分开的语言。
06]版本21以后才有的功能,能打开/另存为Doc,Docx,Html文件,可能有些格式不齐全
061]DOCX文件的加密和解密
01]生成Ribbon工具栏
拖一个RichEditControl到界面,右键,(一定要安装所有DevExpress控件)
最上有Generate,可以生成Ribbon或者ToolBar两种类型的工具栏,不用写一行代码
02]添加 打印预览
拖 一个dxComponentPrinter1到界面上,双击它,
03]添加新 按钮
在最上面Tab右建,点Add Group WithToolbar,新建 Group并生成 空白 Toolbar,可以设置Toolbar的名称Caption
在空白 Toolbar上右键,添加 大按钮Add LargeButton
可以设置大按钮的名称Caption和图标LargeImageIndex
双击它即可添加事件
00]添加绑定 自带事件
01]放一个ActionList1到界面
02]绑定事件
用代码 添加新文本
procedure TForm4.dxBarLargeButton3Click(Sender: TObject);
var
ADocument: IdxRichEditDocument;
begin
ADocument := dxRichEditControl1.Document;
ADocument.BeginUpdate; // You can include multipe append and/or insert text operations between the BeginUpdate and EndUpdate procedure calls
ADocument.AppendText('The quick brown fox jumps over the lazy dog.');
ADocument.EndUpdate;
end;
用代码 添加新文本框
uses
dxCoreGraphics, cxGeometry;
procedure TForm4.dxBarLargeButton3Click(Sender: TObject);
var
ADocument: IdxRichEditDocument;
ATextBoxShape: IdxRichEditShape;
ATextBoxSubDocument: IdxRichEditSubDocument;
begin
ADocument := dxRichEditControl1.Document;
ADocument.&Unit := TdxRichEditDocumentUnit.Point; // Sets the measurement unit used to specify positions and sizes within the document
ATextBoxShape := ADocument.InsertTextBox(ADocument.CreatePosition(0)); // Creates a new empty text box
ATextBoxSubDocument := ATextBoxShape.TextBox.Document;
// Adds text to the text box
ATextBoxSubDocument.AppendText('Lorem ipsum dolor sit amet, eu cum consul ignota. ');
ATextBoxSubDocument.AppendText('Ea purto ubique voluptua nam, ea malorum definebas assueverit mel. ');
ATextBoxSubDocument.AppendText('Qui ea alia mutat petentium ius latine oblique conclusionemque ne.');
ATextBoxShape.TextWrapping := TdxRichEditTextWrappingType.Square; // Anchors the floating text box to the document's text layer and wraps text around all sides of the floating box's bounding rectangle
ATextBoxShape.HorizontalAlignment := TdxRichEditShapeHorizontalAlignment.Center;
ATextBoxShape.Offset := TdxPointF.Create(0, 200);
ATextBoxShape.RotationAngle := 45;
// Sets the floating shape's appearance settings
ATextBoxShape.Line.Thickness := 1;
ATextBoxShape.Line.Color := TdxAlphaColors.Black;
ATextBoxShape.Fill.Color := TdxAlphaColors.Bisque;
// Sets the margins between the text box's bounding rectangle and the parent document's text
ATextBoxShape.MarginBottom := 10;
ATextBoxShape.MarginLeft := 10;
ATextBoxShape.MarginRight := 10;
ATextBoxShape.MarginTop := 10;
end;
04]显示行号
05]拼写检查,支持英文,不支持中文
拖一个dxSpellChecker1到界面上
与生成的exe放一起
dxSpellChecker1.CheckContainer(Self, True);
或者 添加 按钮的 事件 dxRichEditControlCheckSpelling2 ,
事件在DevExpress RichEdit Control.Review.Proofing下
06]版本21以后才有的功能,能打开/另存为Doc,Docx,Html文件,可能有些格式不齐全
061]DOCX文件的加密和解密
dxRichEditControl1.Document.SetEncryptionPassword('Password');
只有DOCX文件格式才支持文档加密。如果其他格式文件保存,控件会提示如下对话框: