in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Windows Forms

XtraSpellChecker: How to Enable Spell Checking

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) {
    spellChecker1.Check(textBox1);
}

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) {
    spellChecker1.CheckContainer(this);
}

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)
        DoCheck();
}

protected virtual void DoCheck() {
    spellChecker1.Check(GetActiveControl());
}

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.

Published Sep 19 2007, 11:08 PM by Alan (Developer Express)
Filed under:
Technorati tags: XtraSpellChecker

Comments

 

Alex Danvy [DX-Squad] said:

More than ever, this spell check component remind me the missing RTF editor from DevExpress ;-)

What about "live" or spell check as you type feature ?

September 20, 2007 1:30 PM
 

Martin Paternoster said:

It would be interesting to be able to obtain this control as a separate product.

At this point, it is only available as part of the DXperience subscriptions.

September 20, 2007 2:11 PM
 

Mehul Harry (Developer Express) said:

Hi Martin,

Thanks for the suggestion. We'll definitely consider it.

September 20, 2007 5:32 PM
 

Mehul Harry (Developer Express) said:

Hi Alex,

The Rich editor is coming soon. :-)

I'll have an update for you soon on the spell check as you type feature. In the meantime you can see the requests and their status here:

www.devexpress.com/.../SearchResults.aspx

Thanks.

September 20, 2007 5:33 PM
 

Windows Forms said:

Did you know that the XtraSpellChecker Suite can check spelling as you type? Just like in MS Word or

September 24, 2007 2:58 PM
 

Mehul Harry (Developer Express) said:

Hi Alex,

Alan has created a post about spell checking as you type here:

community.devexpress.com/.../xtraspellchecker-check-spelling-as-you-type.aspx

Thanks.

September 24, 2007 3:14 PM
 

how to enable word verification said:

Pingback from  how to enable word verification

May 30, 2008 11:22 AM

Leave a Comment

(required)  
(optional)
(required)  
Verification code: Required
   
Add

About Alan (Developer Express)

Joined Developer Express on August 22, 2003
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED