XtraSpellChecker: How to Enable Spell Checking

WinForms Team Blog
19 September 2007

In a previous post, you learned about the XtraSpellChecker component. Now let's dig deeper and see some samples to enable spell checking in your application.

Runtime Samples

The following examples will show you how to use the Check and CheckContainer methods in different ways. These methods allow you to check the spelling of various controls.

Check a TextBox

To check the text of a TextBox control use the following code. You can bind this method to just about any event such as a button click:

private void simpleButton1_Click(object sender, EventArgs e) {

Check any text-aware control

The Check method can check text from any control. Just pass the text value to the Check method and you'll be returned the text processed by the spell-checker engine.

private void simpleButton1_Click(object sender, EventArgs e) {
    myTextControl.Text = spellChecker1.Check(myTextControl.Text);

Check all controls on a form

If you want to check all text-aware controls on a container then just call the CheckContainer method:

private void simpleButton1_Click(object sender, EventArgs e) {

Use a Hotkey like F7

One of the default hotkeys for Microsoft Office is F7 for spell checking. You can provide the same experience and familiarity for your users by binding the F7 key for your form to start spell checking. Below, the F7 key is bound to an XtraGrid Control:

private void gridControl1_EditorKeyDown(object sender, KeyEventArgs e) {
    if (e.KeyCode == Keys.F7 && e.Modifiers == Keys.None)

protected virtual void DoCheck() {

private Control GetActiveControl() {
    return gridControl1.FocusedView.IsEditing ? 
        gridControl1.FocusedView.ActiveEditor : ActiveControl;

Checking via the context menu

Right-clicking to check text is very popular as well. You can easily provide this for certain controls like a Memo control by calling the SpellChecker.SetShowSpellCheckMenu method:

private void MemoEditForm_Load(object sender, EventArgs e) {
    spellChecker1.SetShowSpellCheckMenu(memoEdit1, true);

You now have the "Check Spelling" menu item added to the bottom of the control's context menu:

The "Check Spelling" menu item

Viola, your text-aware controls can now easily be spell checked!

You can try all the samples above for yourself. Just download the following file and open in Visual Studio 2005: SpellCheckerExample.Zip

Are you curious about anything else with the XtraSpellChecker? Just drop me a note or comment here. Thanks.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.