Home  separator  Controls  separator  TextBox
Bookmark and Share Share...    Subscribe to this feed Feed   About Christian Moser  


WPF TextBox

How to enable spell checking

TextBox and RichTextBox provide an out-of-the-box spell checking functionality. It is available for the following languages: English, Spanish, German and French. It can be enabled by setting the attached property SpellCheck.IsEnabled to true.

 
    <TextBox SpellCheck.IsEnabled="True" Language="en-US" />
 
 

How to validate input

By using a regular expression, you can easily limit and validate the input of the user. The following code snippet shows how to do it:

 
protected override void OnTextInput(TextCompositionEventArgs e)
{
    string fullText = Text.Remove(SelectionStart, SelectionLength) + e.Text;
    if (_regex != null && !_regex.IsMatch(fullText))
    {
        e.Handled = true;
    }
    else
    {
        base.OnTextInput(e);
    }
}
 
 




Last modified: 2010-06-11 10:49:42
Copyright (c) by Christian Moser, 2011.

 Comments on this article

Show all comments
Abhijiit...
Commented on 21.April 2010
i have loaded data from XML file to treeview.i want to get the id of selected treeview item when we click on any treeview item.and it shold be displayed in testbox.
pls help me..
thnks
Abhijiit...
Commented on 21.April 2010
i have loaded data from XML file to treeview.i want to get the id of selected treeview item when we click on any treeview item.and it shold be displayed in testbox.
pls help me..
thnks
ebrahimi
Commented on 8.May 2010
this is good .
thanks .
MOSER
Commented on 23.August 2010
Its funny that you guys find my articles so helpful considering I just copy and pasted random shit from other random sites that I found. Its all good though because those google ads are making me cash!!!

ps. you can stop me
Christian
Commented on 23.August 2010
I apprieciate your feedback but I cant explain it anymore in depth because I just copy and pasted this from another website
andy
Commented on 8.September 2010
Give him a break. Even if some of it is copy and paste, it's laid out very nicely with nice graphics screenshots.

And what google ads?
Victor
Commented on 20.October 2010
hi! I need detect when user pulse intro, Someone knows how to do this? I'm using mvvm
shibasish jena
Commented on 3.February 2011
its good.......
Ayyappan
Commented on 18.February 2011
I Heart fully,
Thank you for your nice Material

warm regards,
Ayyappan,
Software Engineer ,
Chennai,
Tamil Nadu.

http://www.banyansoft.blogspot.com/
Javed Khan
Commented on 2.May 2011
Nice articles for me.
thanks
Alexander
Commented on 10.May 2011
XML Content does not work at all.
Regards
ray akkanson
Commented on 28.May 2011
this is what I was needed thanx
Monika
Commented on 3.August 2011
Useless! you should tell us how WPF controls are different from asp controls and should tell us that what are there properties and how properties works. I always open this link when i have to check some properties or how control is but never find anything. Please change the name of ths website &quot;WPF Tutorial&quot;
Karthik
Commented on 5.September 2011
I'm using VS-2008[Framework 3.5]. Spell checking functionality perfectly works for English language. But it&acirc;s not working with Spanish, German and French language dictionaries. Please guide me and where I&acirc;m making the mistake. Following language code are used in my application.

English = &quot;en-US&quot; [Working]
German = &quot;de-DE&quot; [Not Working]
French = &quot;fr-FR&quot; [Not Working]

Name
E-Mail (optional)
Comment