Skip to main content
.NET Framework 4.5.2+

CellRange.SetRichText(RichTextString) Method

Assigns the rich formatted text to a cell.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v22.2.Core.dll


void SetRichText(
    RichTextString value


Name Type Description
value RichTextString

A RichTextString object that is a combination of specifically formatted text regions.


Use the SetRichText method to add rich formatted text to a cell. Such rich text is defined by the RichTextString object and represents a cell text divided into separate regions (so-called text runs), each with its own set of font characteristics.


To apply rich formatting to the cell text, do one of the following:

Pass the RichTextString instance to the SetRichText method to assign the specified rich text to a cell. The resulting text string is also set to the cell’s CellRange.Value as plain text.

// Create a RichTextString instance.
RichTextString richText = new RichTextString();

// Add three text runs. Each run has its own font settings.
richText.AddTextRun("Rich ", new RichTextRunFont("Arial", 14, System.Drawing.Color.FromArgb(0xc5, 0x9f, 0xc9)));
richText.AddTextRun("text ", new RichTextRunFont("Tahoma", 14, System.Drawing.Color.FromArgb(0x2c, 0x60, 0x8e)));
richText.AddTextRun("formatting", new RichTextRunFont("Castellar", 14, System.Drawing.Color.FromArgb(0x2f, 0x24, 0x4f)));

// Assign the rich formatted text to the cell B2.

For more examples on how to apply different fonts to specific regions of the cell text, refer to the How to: Apply Rich Formatting to Cell Text document.

See Also