Knowledgebase Home Page  >  Thesaurus Desktop .NET
Search the Knowledge Base
How do I integrate with Dev Express controls? (C#, VB.NET)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=153&catId=53

Options

Print this page
Email this to a friend

The RapidSpell Desktop .NET product includes Dev Express demos that show how to add spell checking to controls such as XtraGrid, MemoExEdit, MemoEdit etc.  To do this a 'glue' class is included which provides a version agnostic way to interface our controls with theirs.

Please see the attachment (bottom of page) to a complete VB.NET demo project.

To add Thesaurus support to MemoEdit (and implicitly MemoExEdit) for example, the glue class can be modified as follows;

1. Locate the AYTMemoEdit class in the RapidSpell_DevExpressAdapter_Glue file - add the following two fields to the class

'VB

Private thesaurus1 As Keyoti.Thesaurus.Windows.Thesaurus

Friend WithEvents thesContextMenu As ContextMenu

//C#

Keyoti.Thesaurus.Windows.Thesaurus thesaurus1;

ContextMenu thesContextMenu;

 

2. This class has a method named CreateMaskBoxInstance, add the following code immediately before the call to "rapidSpellAsYouType1.TextComponent = connector"

'VB

thesaurus1 = New Keyoti.Thesaurus.Windows.Thesaurus

thesaurus1.TextBoxBase = tb

rapidSpellAsYouType1.ShowSuggestionsContextMenu = False

thesContextMenu = New ContextMenu

tb.ContextMenu = thesContextMenu

 

//C#

thesaurus1 = new Keyoti.Thesaurus.Windows.Thesaurus();
thesaurus1.TextBoxBase tb;
rapidSpellAsYouType1.ShowSuggestionsContextMenu = false;
thesContextMenu = new ContextMenu();
tb.ContextMenu thesContextMenu;

thesContextMenu.Popup += new EventHandler(thesContextMenu_Popup);

 

3. Add the context menu popup event handler, this is standard suggested thesaurus popup handler code

'VB

Private Sub thesContextMenu_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles thesContextMenu.Popup

thesContextMenu.MenuItems.Clear()

'see if any spelling suggestions

Dim spellingSuggestions As MenuItem() = Me.rapidSpellAsYouType1.GetSuggestions()

If Not (spellingSuggestions Is Nothing) Then

thesContextMenu.MenuItems.AddRange(spellingSuggestions)

thesContextMenu.MenuItems.Add("-")

End If

'add synonymns (thesaurus submenu), if not in header/footer

Dim synonymsMenuItem As New MenuItem("Synonyms")

thesContextMenu.MenuItems.Add(synonymsMenuItem)

Dim thSuggestions As MenuItem() = Me.thesaurus1.GetSuggestionMenuItems()

Dim noSuggestionsMenuItem As New MenuItem("(No suggestions)")

noSuggestionsMenuItem.Enabled = False

synonymsMenuItem.MenuItems.Clear()

If Not (thSuggestions Is Nothing) Then

synonymsMenuItem.MenuItems.AddRange(thSuggestions)

Else

synonymsMenuItem.MenuItems.Add(noSuggestionsMenuItem)

End If

End Sub

 //C#

    private void thesContextMenu_Popup(object sender, System.EventArgs e) {
        thesContextMenu.MenuItems.Clear()
;
        
// see if any spelling suggestions
        
MenuItem[] spellingSuggestions = this.rapidSpellAsYouType1.GetSuggestions();
        if 
(!(spellingSuggestions == null)) {
            thesContextMenu.MenuItems.AddRange(spellingSuggestions)
;
            
thesContextMenu.MenuItems.Add("-");
        
}
        
// add synonymns (thesaurus submenu), if not in header/footer
        
MenuItem synonymsMenuItem = new MenuItem("Synonyms");
        
thesContextMenu.MenuItems.Add(synonymsMenuItem);
        
MenuItem[] thSuggestions = this.thesaurus1.GetSuggestionMenuItems();
        
MenuItem noSuggestionsMenuItem = new MenuItem("(No suggestions)");
        
noSuggestionsMenuItem.Enabled = false;
        
synonymsMenuItem.MenuItems.Clear();
        if 
(!(thSuggestions == null)) {
            synonymsMenuItem.MenuItems.AddRange(thSuggestions)
;
        
}
        
else {
            synonymsMenuItem.MenuItems.Add(noSuggestionsMenuItem)
;
        
}
    }

 

By doing this a 'synonyms' menu item should appear when right clicking on a correctly spelled word, and spelling should appear when right clicking on an incorrectly spelled word.


Related Questions:

Attachments: