/// <summary>
/// Converts the casing of selected text in SfRichTextBoxAdv.
/// </summary>
/// <param name="isLower">Specifies whether the text to be converted in lower case.</param>
public void ConvertCase(bool isLower)
{
// Gets the selected text.
string text = richTextBoxAdv.Selection.Text;
// Converts the casing of selected text.
string replaceText = isLower ? text.ToLower() : text.ToUpper();
if (!text.Equals(replaceText))
{
// Store the current selection positions.
string start = richTextBoxAdv.Selection.Start.GetHierarchicalIndex;
string end = richTextBoxAdv.Selection.End.GetHierarchicalIndex;
// Replace the text to converted casing.
richTextBoxAdv.Selection.InsertText(replaceText);
// Restore the selection positions.
richTextBoxAdv.Selection.Select(richTextBoxAdv.Document.GetTextPosition(start),
richTextBoxAdv.Document.GetTextPosition(end));
}
} |