The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

RichTextString.AddTextRun(String, RichTextRunFont) Method

Appends a new text run to the current rich text string.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

public RichTextString AddTextRun(string text, RichTextRunFont font)
Public Function AddTextRun(text As String, font As RichTextRunFont) As RichTextString
public RichTextString AddTextRun(string text, RichTextRunFont font)
Public Function AddTextRun(text As String, font As RichTextRunFont) As RichTextString

Parameters

Name Type Description
text String

A String value that specifies the current run's text.

font RichTextRunFont

A RichTextRunFont object that specifies font attributes to be applied to the text.

Parameters

Name Type Description
text String

A String value that specifies the current run's text.

font RichTextRunFont

A RichTextRunFont object that specifies font attributes to be applied to the text.

Returns

Type Description
RichTextString

A RichTextString object that specifies rich text contained in a cell.

Returns

Type Description
RichTextString

A RichTextString object that specifies rich text contained in a cell.

Remarks

Use the AddTextRun method to compose the cell text from individual text runs. Call the Range.SetRichText method to assign the rich formatted text to a cell.

// 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.
worksheet["B2"].SetRichText(richText);

You can also use the RichTextString.Characters property to format specific characters within a cell text. Refer to the How to: Apply Rich Formatting to Cell Text article for more examples on how to apply rich formatting to the cell content.

See Also