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

ComponentOne Spell for TX Text Control .NET

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:Visual Basic .NET
Version:1.0
Released:August 06, 2004
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Studio .NET
Download code:txcode50.zip Download [26.1 KB, ZIP]

Spell Checking in TX Text Control .NET

We are often asked which spell checking control to use with TX Text Control. For several years, we have been recommending the VSSpell OCX control as it is both powerful and flexible. This control is now available as a .NET component.

This week we would like to show you how this success story continues with the just-released TX Text Control .NET.

We are going to use the method CheckString from ComponentOne Spell for .NET with a plain text string that is saved by the TX Text Control in to a variable.

  1. Dim sData As String
  2.  
  3. TextControl1.Save(sData, TXTextControl.StringStreamType.PlainText)
  4. sData = sData.Replace(vbCr, "")
  5. C1Spell1.CheckString(sData, C1.Win.C1Spell.BadWordDialogEnum.EnglishDialog)
  6. C1Spell1.Clear()

If a mispelled word has been found by the spell checking component, the BadWord event is fired. It returns the character index and the length of the word which has to be selected by TX Text Control.

  1. Private Sub C1Spell1_BadWord(ByVal sender As Object,
  2. ByVal e As C1.Win.C1Spell.BadWordEventArgs) Handles C1Spell1.BadWord
  3. TextControl1.Selection.Start = C1Spell1.SelStart
  4. TextControl1.Selection.Length = C1Spell1.SelLength
  5. End Sub

Now, the spell checker provides two change actions: The first changes the misspelled word to a selected word from the suggestion list and the second changes all words to that specified word. The DialogAction event returns the change state which indicates whether the 'Change' or 'Change All' button has been clicked. If 'Change All' has been clicked, all occurrences of the misspelled word will be searched in the document and will be replaced with the new word.

  1. While (FindSuccess <> -1)
  2. TextControl1.Selection.Text = C1Spell1.DialogChangedWord
  3. NewPos = NewPos + TextControl1.Selection.Length
  4. FindSuccess = TextControl1.Find(C1Spell1.CheckWord, NewPos,
  5. TXTextControl.FindOptions.NoMessageBox)
  6. End While

If 'Change' has been clicked, only the selected word will be replaced.

  1. TextControl1.Selection.Text = C1Spell1.DialogChangedWord

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