Back to Devexpress

RichEditControl.LayoutUnit Property

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-3a28f07f.md

latest5.0 KB
Original Source

RichEditControl.LayoutUnit Property

Gets or sets a unit of measure used for a document layout. Starting from v18.1, the property has no effect.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public DocumentLayoutUnit LayoutUnit { get; set; }
vb
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Property LayoutUnit As DocumentLayoutUnit

Property Value

TypeDescription
DocumentLayoutUnit

One of the DocumentLayoutUnit enumeration values. The default is DocumentLayoutUnit.Pixel.

|

Available values:

NameDescription
Document

Specifies documents (one three-hundredths of an inch) as measurement units.

| | Twip |

Specifies twips (1,440 twips equal one inch, and 567 twips equal one centimeter) as measurement units.

| | Pixel |

Specifies pixels as measurement units.

|

Remarks

Before v.18.1, a document would not accurately print or properly display on devices with different DPI settings. The issue is caused by different measure units used to calculate the display and printout layouts. The display layout is calculated in DocumentLayoutUnit.Pixel by default, which is best suited for a screen display. The print layout is calculated in DocumentLayoutUnit.Document.

Use the LayoutUnit property to adjust the document’s look. Set the LayoutUnit to DocumentLayoutUnit.Pixel to improve text rendering and the overall display appearance. For a more accurate layout, specify DocumentLayoutUnit.Twip as the unit of measurement. Note that changing layout units for display may lead to document corruption when appearing on screen.

Important

With the RichEditControlCompatibility.EnableLegacyLayoutEngine property set to false , the LayoutUnit property doesn’t affect the document model layout calculation. Set the RichEditControlCompatibility.EnableLegacyLayoutEngine property set to true on application startup to manage the document layout manually. Refer to the How to: Perform Actions On Application Startup topic for details.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the LayoutUnit property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richedit-enable-line-numbering-and-count-document-rows/CS/LineNumberingExample/MyPagePainter.cs#L61

csharp
public override void DrawLineNumberBox(LineNumberBox lineNumberBox) {
    Canvas.DrawString(lineNumberBox.Text, lineNumberFont, new RichEditBrush(NumberingFontColor), lineNumberBox.Bounds, this.richEditControl.LayoutUnit);
}

winforms-richedit-enable-line-numbering-and-count-document-rows/VB/LineNumberingExample/MyPagePainter.vb#L74

vb
Public Overrides Sub DrawLineNumberBox(ByVal lineNumberBox As LineNumberBox)
    Canvas.DrawString(lineNumberBox.Text, lineNumberFont, New RichEditBrush(NumberingFontColor), lineNumberBox.Bounds, richEditControl.LayoutUnit)
End Sub

See Also

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace