Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Implementing 'Change Case' feature

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:Visual Basic .NET
Version:1.0
Released:March 16, 2005
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Basic .NET
Download code:case_change.zip Download [8.18 KB, ZIP]

Implementing a 'Change Case' feature with TX Text Control

Click to enlarge

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:

  1. selChar = TextControl1.Selection.Text
  2. If selChar.IsLetter(selChar) = True Then
  3. TextControl1.Selection.Text = selChar.ToUpper(selChar)
  4. 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 trial version and Visual Studio .NET 2003.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place