TX Text Control .NET for Windows Forms

ChangeCapitalization Method

Method|Introduced in 30.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Changes the capitalization of all selected characters depending on the settings parameter.

Syntax

public bool ChangeCapitalization(CapitalizationSettings cs);

Parameters

ParameterDescription
cs

Specifies how the capitalization is changed. It can be one of the CapitalizationSettings values:

ValueMeaning
CapitalizeEachSentenceThe first letter of each sentence is capitalized.
CapitalizeEachWordThe first letter of each word is capitalized.
ToLowerAll letters are changed to lowercase.
ToUpperAll letters are changed to uppercase.
ToggleCaseLowercase letters are changed to uppercase and vice versa.

Return Value

The return value is false, if there is no selected text or if an error has occurred. Otherwise it is true.

Examples

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

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

if (selection.ChangeCapitalization(CapitalizationSettings.ToUpper))
{
    Console.WriteLine("Change Capitalization completed successfully.");
}