.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

SubDocument.BeginUpdateCharacters(DocumentPosition, Int32) Method

Starts modifying properties of the specified number of characters starting at the specified document position.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v20.2.Core.dll

Declaration

CharacterProperties BeginUpdateCharacters(
    DocumentPosition start,
    int length
)

Parameters

Name Type Description
start DocumentPosition

A DocumentPosition, specifying the starting document position.

length Int32

An integer specifying the number of positions to which formatting is applied.

Returns

Type Description
CharacterProperties

A CharacterProperties object representing the character formatting of the specified range.

Remarks

Use the SubDocument.BeginUpdateCharacters and the SubDocument.EndUpdateCharacters paired methods to modify character formatting, such as the CharacterPropertiesBase.FontName, CharacterPropertiesBase.FontSize, CharacterPropertiesBase.Bold, CharacterPropertiesBase.ForeColor etc.

To accomplish this, call the SubDocument.BeginUpdateCharacters method for the specified range, use the returned CharacterProperties interface to modify the required properties and call the SubDocument.EndUpdateCharacters method to finalize the modification.

NOTE

Make sure that the SubDocument.BeginUpdateCharacters method always has its corresponding SubDocument.EndUpdateCharacters method to ensure proper operation of the control.

The following code snippet changes the font and the color of the selected text.

document.BeginUpdate();
document.AppendText("Normal\nFormatted\nNormal");
document.EndUpdate();
// The target range is the second paragraph 
DocumentRange range = document.Paragraphs[1].Range;

// Create and customize an object  
// that sets character formatting for the selected range
CharacterProperties cp = document.BeginUpdateCharacters(range);
cp.FontName = "Comic Sans MS";
cp.FontSize = 18;
cp.ForeColor = Color.Blue;
cp.BackColor = Color.Snow;
cp.Underline = UnderlineType.DoubleWave;
cp.UnderlineColor = Color.Red;

// Finalize modifications  
// with this method call 
document.EndUpdateCharacters(cp);
See Also