Example E3781
Visible to All Users

Rich Text Editor for WinForms - How to Adjust the Left Padding of a Document

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

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

Form1.cs(vb)
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); } } }
Program.cs(vb)
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()); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.