TX Text Control .NET for Windows Forms

FontName Property

Property
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets or sets the font of the selected text.

Syntax

public string FontName { get; set; }

Examples

The following example formats the heading of a short document by using Selection.FontName.

textControl.Text = "Quarterly results\nRevenue increased by 12%.";
textControl.Select(0, 17);
Selection selection = textControl.Selection;

selection.FontName = "Arial";
if (!string.IsNullOrWhiteSpace(selection.FontName))
{
    Console.WriteLine($"Font Name: {selection.FontName}");
}

Limitations

Runtime only.

Remarks

The property returns an empty string when the text selection contains multiple characters with mixed font names. The Selection.IsCommonValueSelected method can be used to check for mixed attributes.