Skip to main content

How to: Change Formatting of the Current Paragraph

using System.Windows;
using System.Drawing;
using DevExpress.XtraRichEdit;
using DevExpress.Office.Utils;
using DevExpress.XtraRichEdit.API.Native;
//...

Document doc = richEditControl1.Document;
DocumentRange range = doc.Selection;
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);