Skip to main content

RichEditControl.MeasureSingleLineString(String, CharacterPropertiesBase) Method

Calculates the length of a formatted string.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v22.2.dll

NuGet Package: DevExpress.Win.RichEdit


public SizeF MeasureSingleLineString(
    string text,
    CharacterPropertiesBase properties


Name Type Description
text String

A string to measure.

properties CharacterPropertiesBase

A CharacterPropertiesBase interface specifying formatting used to display a string.


Type Description

A SizeF object that is the rectangle required to display a string.


The following code snippet illustrates the use of a MeasureSingleLineString method, to calculate required size of a tab stop. Tab stop position is specified by the TabInfo.Position property and measured in units of a current document (Document.Unit value). To provide a uniform tab stops for a certain number of characters, we specify a monospaced font as the default document font and measure the length of a string containing required number of characters.

View Example

using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Utils;
using DevExpress.Office.Utils;
            Document document = richEditControl1.Document;
            SizeF tabSize = richEditControl1.MeasureSingleLineString(new String(' ', 4), document.DefaultCharacterProperties);
            TabInfoCollection tabs = document.Paragraphs[0].BeginUpdateTabs(true);
            try {
                for (int i = 1; i <= 30; i++) {
                    DevExpress.XtraRichEdit.API.Native.TabInfo tab = new DevExpress.XtraRichEdit.API.Native.TabInfo();
                    tab.Position = i * tabSize.Width;
            finally {
See Also