| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| 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 |
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.

Dim sData As String TextControl1.Save(sData, TXTextControl.StringStreamType.PlainText) sData = sData.Replace(vbCr, "") C1Spell1.CheckString(sData, C1.Win.C1Spell.BadWordDialogEnum.EnglishDialog) 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.
Private Sub C1Spell1_BadWord(ByVal sender As Object, ByVal e As C1.Win.C1Spell.BadWordEventArgs) Handles C1Spell1.BadWord TextControl1.Selection.Start = C1Spell1.SelStart TextControl1.Selection.Length = C1Spell1.SelLength 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.
While (FindSuccess <> -1) TextControl1.Selection.Text = C1Spell1.DialogChangedWord NewPos = NewPos + TextControl1.Selection.Length FindSuccess = TextControl1.Find(C1Spell1.CheckWord, NewPos, TXTextControl.FindOptions.NoMessageBox) End While
If 'Change' has been clicked, only the selected word will be replaced.
TextControl1.Selection.Text = C1Spell1.DialogChangedWord