cyh 发表于 2014-11-5 09:25:20

DEV 中RichEditControl 设置改变段落默认格式

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.Utils;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.Office.Utils;

            Document doc = richEditControl1.Document;
            DocumentPosition pos = doc.Selection.Start;
            DocumentRange range = doc.CreateRange(pos, 0);
            ParagraphProperties pp = doc.BeginUpdateParagraphs(range);
            // Center paragraph
            pp.Alignment = ParagraphAlignment.Center;
            // Set triple spacing
            pp.LineSpacingType = ParagraphLineSpacing.Multiple;
            pp.LineSpacingMultiplier = 3;
            // Set left indent at 0.5".
            // Default unit is 1/300 of an inch (a document unit).
            pp.LeftIndent = Units.InchesToDocumentsF(0.5f);
            // Set tab stop at 1.5"
            TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
            TabInfo tbi = new TabInfo();
            tbi.Alignment = TabAlignmentType.Center;
            tbi.Position = Units.InchesToDocumentsF(1.5f);
            tbiColl.Add(tbi);
            pp.EndUpdateTabs(tbiColl);
            doc.EndUpdateParagraphs(pp);
页: [1]
查看完整版本: DEV 中RichEditControl 设置改变段落默认格式