DevExpress21中dxRichEditControl控件学习全功能展示及完全汉化效果
链接:https://pan.baidu.com/s/1PLStQSZEqe4oDKrVtON6ow
提取码:glit
仅源文件
链接:https://pan.baidu.com/s/19U3DnYkqRPfDGZRYUMBpcg
提取码:zyd3
解决办法:
03]添加新 按钮 和文本框
030添加绑定自带事件
031用代码 添加新文本
032用代码 添加新文本框
033]添加角标按钮及事件,弹出字体选择对话框
05]拼写检查,支持英文,不支持中文.只支持 空格分开的语言。
06]版本21以后才有的功能,能打开/另存为Doc,Docx,Html文件,可能有些格式不齐全
16]dxRibbonStatusBar1特有状态栏Toolbar Panel
拖一个RichEditControl到界面,右键,(一定要安装所有DevExpress控件)
最上有Generate,可以生成Ribbon或者ToolBar两种类型的工具栏,不用写一行代码
拖 一个dxComponentPrinter1到界面上,双击它,
在最上面Tab右建,点Add Group WithToolbar,新建 Group并生成 空白 Toolbar,可以设置Toolbar的名称Caption
在空白 Toolbar上右键,添加 大按钮Add LargeButton
可以设置大按钮的名称Caption和图标LargeImageIndex,名称中有空格即可换行
双击它即可添加事件
除了按钮,还可以添加文本框之类的
01]放一个ActionList1到界面
02]绑定自带事件
随便找一个dxBarLargeButton后,点Action
回车后,就生成相应事件dxRichEditControlShowFontForm1
,就可以用dxRichEditControlShowFontForm1.Execute;调用
所有dxRichEditControl事件.
往下拉
所有事件在帮助里列明了
先在Action里添加dxRichEditControlShowFontForm1事件
procedure TForm10.dxBarFontCaptionButtons0Click(Sender: TObject); begin dxRichEditControlShowFontForm2.Execute; end;
用代码 添加新文本
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;
拖一个dxSpellChecker1到界面上
与生成的exe放一起
dxSpellChecker1.CheckContainer(Self, True);
或者 添加 按钮的 事件 dxRichEditControlCheckSpelling2 ,
事件在DevExpress RichEdit Control.Review.Proofing下
06]版本21以后才有的功能,能打开/另存为Doc,Docx,Html文件,可能有些格式不齐全
dxRichEditControl1.Document.SetEncryptionPassword('Password');
只有DOCX文件格式才支持文档加密。如果其他格式文件保存,控件会提示如下对话框:
uses dxRichEdit.View.Core ; //获取当前的页数 dxRichEdit.View.Core.TdxPageBasedRichEditView(dxRichEditControl1.ActiveView).CurrentPageIndex; //获取总页数 dxRichEdit.View.Core.TdxPageBasedRichEditView(dxRichEditControl1.ActiveView).PageCount;
将这个StatusBar过程放到dxRichEditControl1MouseUp和dxRichEditControl1KeyUp,等事件,来更新状态栏数据
uses dxRichEdit.View.Core ; procedure TForm10.StatusBar; var currentPageIndex:integer; currentPageCount :integer; begin //获取当前的页数 currentPageIndex:= dxRichEdit.View.Core.TdxPageBasedRichEditView(dxRichEditControl1.ActiveView).CurrentPageIndex; //获取总页数 currentPageCount:= dxRichEdit.View.Core.TdxPageBasedRichEditView(dxRichEditControl1.ActiveView).PageCount; dxRibbonStatusBar1.Panels[0].Text := '页面:'+ inttostr(currentPageIndex+1) +'/'+ inttostr(currentPageCount);
dxRibbonStatusBar1.Panels[1].Text := '字数:' + inttostr(dxRichEditControl1.Document.Text.Length); end;
procedure TForm1.dxRichEditControl1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin StatusBar; end;
procedure TForm1.dxRichEditControl1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin // 如果按下 Insert 切换 插入/改写 模式。 默认初始状态为 插入 if Key = 45 then // Insert KeyCode begin if dxRibbonStatusBar1.Panels[2].Text = '改写' then dxRibbonStatusBar1.Panels[2].Text := '插入' else dxRibbonStatusBar1.Panels[2].Text := '改写'; end; StatusBar; end;
09]获得已选择文本
showmessage(
dxRichEditControl1.Document.GetText(dxRichEditControl1.Document.Selection)
);
设置Action为dxRichEditControlZoomPercent1
可以修改
增加缩放比例
11]用浏览器打开超链接/删除超链接
添加自带事件dxRichEditControlOpenHyperlink1
类似地,删除超链接dxRichEditControlRemoveHyperlinkField1
输入完整网址超链接后,回车
procedure TForm10.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin case application.MessageBox('确定退出dxRichEditControl1,是否保存?', '询问', 35) of 6: begin //保存 dxRichEditControl1.SaveDocument; //退出 CanClose:=true; end; 7: begin //不保存,退出 CanClose:=true; end; 2: begin //取消 关闭 ,返回 dxRichEditControl1 CanClose:=false; end; end; end;
添加dxRichEditControlShowNumberingForm1事件
比如,我要把Page Layout移动到[公式]后面
每个PageTab菜单栏都有一个Context属性
理解为,单击 表格,就弹出与 表格 相关的PageTab菜单栏
16]dxRibbonStatusBar1特有状态栏Toolbar Panel
三种视图
缩放显示