Back to Devexpress

RichTextRange.Font Property

officefileapi-devexpress-dot-spreadsheet-dot-richtextrange.md

latest3.1 KB
Original Source

RichTextRange.Font Property

Provides access to font settings for the current region of the cell text.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
SpreadsheetFontProperties Font { get; }
vb
ReadOnly Property Font As SpreadsheetFontProperties

Property Value

TypeDescription
SpreadsheetFontProperties

A SpreadsheetFontProperties object that contains font attributes applied to the current region of the cell text.

|

Remarks

Use the RichTextRange.Text and Font properties of the RichTextRange object to view or change the content and font characteristics for a portion of the cell text defined by the RichTextString.Characters method.

The following example shows how to apply rich formatting to a cell that already contains a text value.

csharp
// Set a cell value.
worksheet["B2"].Value = "Rich text formatting";

// Obtain the RichTextString object containing the cell text.
RichTextString richText = worksheet["B2"].GetRichText();
// Format the first word as bold. 
richText.Characters(0, 4).Font.Bold = true;

// Assign the rich formatted text to the cell B2.
worksheet["B2"].SetRichText(richText);
vb
' Set a cell value.
worksheet("B2").Value = "Rich text formatting"

' Obtain the RichTextString object containing the cell text.
Dim richText As RichTextString = worksheet("B2").GetRichText()
' Format the first word as bold. 
richText.Characters(0, 4).Font.Bold = True

' Assign the rich formatted text to the cell B2.
worksheet("B2").SetRichText(richText)

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

Characters

Text

How to: Apply Rich Formatting to Cell Text

RichTextRange Interface

RichTextRange Members

DevExpress.Spreadsheet Namespace