RichTextBox: Using TX Spell .NET with multiple RichTextBox instances

Integrating TX Spell .NET for Windows Forms with TX Text Control requires no code - it can be easily connected using the Visual Studio designer. To increase performance, the spelling dialog is opened by TX Text Control and not TX Spell .NET. The dialog that is opened by TX Text Control is pre-configured and can't be customized. Alternatively, you can open a fully customizable SpellCheckDialog from TX Spell .NET.

The source code is contained in the following directories:

Using TX Spell .NET with multiple RichTextBox instances

A high-performance spell checker requires a well-considered concept to work with multiple controls on a form in the same application. A single TX Spell .NET instance can be used with multiple instances of the RichTextBox. It is not necessary to have one instance of the spell checker for each instance of the RichTextBox, any other control of the .NET Framework or third-party control. This dramatically reduces the required memory and speeds up the spell checking process.

The concept of using multiple instances of the RichTextBox with the same instance of TX Spell .NET is very straightforward. It is not neccessary to switch manually between the controls. When text is changed in one of the RichTextBoxes, the Proofing.TXSpellChecker.Check method is called and the misspelled words are colorized:

[C#]
txSpellChecker1.Check(richTextBox.Text);
foreach (TXTextControl.Proofing.IncorrectWord incorrectWord in txSpellChecker1.IncorrectWords)
{
	if (incorrectWord.Start <= textPosition && textPosition <= incorrectWord.Start + incorrectWord.Length)
	{
		richTextBox.Select(incorrectWord.Start, incorrectWord.Length);
		richTextBox.SelectionColor = System.Drawing.Color.Red;
		richTextBox.SelectionLength = 0;
		richTextBox.SelectionStart = lastTextPosition;
		return;
	}
}
[Visual Basic]
txSpellChecker1.Check(richTextBox.Text)
For Each incorrectWord As TXTextControl.Proofing.IncorrectWord In txSpellChecker1.IncorrectWords
	If incorrectWord.Start <= textPosition AndAlso textPosition <= incorrectWord.Start + incorrectWord.Length Then
		richTextBox.[Select](incorrectWord.Start, incorrectWord.Length)
		richTextBox.SelectionColor = System.Drawing.Color.Red
		richTextBox.SelectionLength = 0
		richTextBox.SelectionStart = lastTextPosition
		Return
	End If
Next

Start the application and type text into each of the RichTextBoxes. Misspelled words are colorized in red automatically.