This example illustrates how to adjust indent settings in code. You can change the indent of the first document paragraph, or adjust the padding settings of a specific RichEdit view.
Files to Review
- Form1.cs (VB: Form1.vb)
- Program.cs (VB: Program.vb)
Documentation
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#using System;
using System.Windows.Forms;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Utils;
using DevExpress.Office.Utils;
using DevExpress.Portable;
namespace RichEditLeftPadding {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
AdjustSimpleViewPadding();
AdjustDraftViewPadding();
richEditControl1.ActiveViewType = RichEditViewType.Simple;
richEditControl1.Text = "Test";
}
private void richEditControl1_DocumentLoaded(object sender, EventArgs e) {
//AdjustParagraphIndent();
AdjustMargins();
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
AdjustParagraphIndent();
}
private void AdjustSimpleViewPadding() {
richEditControl1.Views.SimpleView.Padding = new PortablePadding(0);
}
private void AdjustDraftViewPadding() {
richEditControl1.Views.DraftView.Padding = new PortablePadding(0);
}
private void AdjustParagraphIndent() {
richEditControl1.Document.Paragraphs[0].LeftIndent = Units.InchesToDocumentsF(0.5f);
richEditControl1.Document.Paragraphs[0].FirstLineIndentType = ParagraphFirstLineIndent.Indented;
richEditControl1.Document.Paragraphs[0].FirstLineIndent = Units.InchesToDocumentsF(0.5f);
}
private void AdjustMargins() {
richEditControl1.Document.Sections[0].Margins.Left = Units.InchesToDocumentsF(2f);
}
}
}
C#using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace RichEditLeftPadding {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}