Skip to main content
A newer version of this page is available. .

How to: Use the SharedDictionaryStorage Component

  • 2 minutes to read

The SharedDictionaryStorage component is implemented to facilitate the usage of multiple dictionaries in an application. The procedure for loading dictionaries takes time, so it’s most efficient not to do it twice, but use already loaded dictionaries for all forms.

In this example we add the component to the application’s main form and specify the necessary dictionaries.

The SharedDictionaryStorage component shortcut is located near the XtraSpellChecker component in the Visual Studio toolbox.

Icons

Drop it onto the main form of your application. A new icon will appear in a component tray. Select it and press F4 to view its property page. Click the Dictionary item in the property grid to invoke the dictionary collection editor.

Assuming that our application will contain text in English and French, we must add dictionaries for both languages, and two custom dictionaries to provide the ability for the user to add special terms and names. The main dictionaries could be obtained from the official page of OpenOffice project, or elsewhere. For the custom dictionaries create two empty files: custom_en-us.dic and custom_fr-fr.dic.

Add two SpellCheckerOpenOfficeDictionary items and two SpellCheckerCustomDictionary items using the Add button of the SpellCheckerDictionaryBase Collection Editor.

Specify the paths to en_US.dic, en_US.aff files for the English, and fr_FR.dic and fr_FR.aff files for the French OpenOffice dictionaries. Notice that the encoding is set automatically to Western European (ISO) for the English, and Latin 9 (ISO) for the French dictionaries. Select the corresponding culture from the list - English (US) for the English dictionary and French (France) for the French.

Specify the paths to custom_en-us.dic and custom_fr-fr.dic files created earlier. Set the culture as you did for the OpenOffice dictionaries, manually specifying the encoding identically for the particular culture, as for the corresponding OpenOffice dictionary.

That’s all. For the XtraSpellChecker to make use of this SharedStorageDictionary component, you should set the SpellCheckerBase.UseSharedDictionaries property to true.

Note

The dictionary files are loaded and processed on first call to the check routines of the XtraSpellChecker. You may test the SpellCheckerDictionaryBase.WordCount property of the dictionaries to be sure that they are properly initialized.