TX Text Control Source Code Library

Implementing 'Change Case' feature

A desirable feature of a word processing application is to change the case of a word, sentence or entire document.

This .NET based sample application illustrates how to implement the different cases known from Microsoft Word.

We are going to implement the following case changes:

  • Sentence case
  • lower case
  • UPPER CASE
  • Title Case
  • toGGLE cASE

The implementation is really simple. We just loop through the selected text and replace the current character with its newly specified case. If the current character is to be converted to an upper case character, it is replaced using this simplified code:

selChar = TextControl1.Selection.Text If selChar.IsLetter(selChar) = True Then TextControl1.Selection.Text = selChar.ToUpper(selChar) End If

The Char namespace of .NET offers the functions toUpper and toLower that can be used to change the case of characters.

In the sample application, you will see how the other cases are implemented and which constraints need to be followed.

The minimum requirements for this sample application are TX Text Control .NET for Windows Forms trial version and Visual Studio .NET 2003.

 
 

Products

Support

Downloads

Corporate

Buy Now