Group 2: TextBox AutoComplete

The second group box consists only of a TextBox. Start typing a word that will be completed automatically based on the current dictionary.

The AutoCompleteMode of the TextBox is set to Suggest and the AutoCompleteMode property to CustomSource. TX Spell .NET is used to fill the custom source with the appropriate suggestions.

private void tbDemo2_TextChanged(object sender, EventArgs e)
	if (acscAutoCompleteCollection == null)
		acscAutoCompleteCollection = new AutoCompleteStringCollection();


	if (txSpellChecker1.IncorrectWords.Count > 0)
		txSpellChecker1.CreateSuggestions(txSpellChecker1.IncorrectWords[0].Text, 10);

		foreach (TXTextControl.Proofing.Suggestion suggestion in txSpellChecker1.Suggestions)

		tbDemo2.AutoCompleteCustomSource = acscAutoCompleteCollection;
[Visual Basic]
Private Sub tbDemo2_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles tbDemo2.TextChanged
	If acscAutoCompleteCollection Is Nothing Then
		acscAutoCompleteCollection = New AutoCompleteStringCollection()
	End If


	If TxSpellChecker1.IncorrectWords.Count > 0 Then
		TxSpellChecker1.CreateSuggestions(TxSpellChecker1.IncorrectWords(0).Text, 10)

		For Each suggestion As TXTextControl.Proofing.Suggestion In TxSpellChecker1.Suggestions

		tbDemo2.AutoCompleteCustomSource = acscAutoCompleteCollection
	End If
End Sub

After checking the text using the TXSpell.Check method, suggestions are created using TXSpell.CreateSuggestions. The number of suggestions is limited to 10 words per misspelled word. Finally, the text of each suggestion is added to the AutoCompleteCollection thats acts as the customer source for the auto completion process.