C# Spell checker Problem

这一生的挚爱 提交于 2019-12-06 21:05:30

I tried using your sample code and it didn't work out as well as it should, so I tried MSDN's tutorial on the subject.

That said, I find it a rather hacky solution. As regards your main form blurring up, I guess it's because it stops responding while you are in the spellchecking window? You might be able to get around it by using a new thread.

Also, you're right, it is launching MS Word, and then hiding the window.

Personally, I'd rather use a library like NetSpell instead of relying on Office.

My working and tested code snippet is as follow:

string s1 = textBox1.Text;

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();

Microsoft.Office.Interop.Word._Document doc = app.Documents.Add();

doc.Words.First.InsertBefore(s1);

Microsoft.Office.Interop.Word.ProofreadingErrors errors = doc.SpellingErrors;

int errorCount = errors.Count;

doc.CheckSpelling(Missing.Value, true, false);

app.Quit(false);

textBox3.Text = errorCount.ToString();

Application with wrong text.

Windows showing wrong word as red highlighted text.

Total error count is being showed at the end.

Solution is taken from my blog.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!