Windows窗体中的拼写检查类? [英] SpellCheck Class in Windows forms?

查看:116
本文介绍了Windows窗体中的拼写检查类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Windows窗体文本框中使用SpellCheck类?

Is it possible to use the SpellCheck class in a Windows forms textbox?

推荐答案

嗨kingelk,

Hi kingelk,

我建议您使用WPF来实现它,WPF中的textBox 控件使用SpellCheck类更简单。

I suggest you use WPF to achieve it, the textBox control in WPF has the Simpler usage with SpellCheck Class.

但是,在Windows窗体中使用它可能更难,但是  ;我们可以实现相同的功能,请参考以下步骤(VB.NET):

However, it maybe more difficult to use it in windows forms, but we can achieve the same function, please refer to the following step(VB.NET):

1,添加一个类似的引用:

1, Add a reference same like:

2,然后参考以下代码:

2, Then refer the below code:

Imports Microsoft.Office.Interop
Public Class Form1
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.LostFocus
        If TextBox1.Text.Length > 0 Then
            Dim wordApp As New Word.Application
            wordApp.Visible = False
            Dim doc As Word.Document = wordApp.Documents.Add()
            Dim range As Word.Range
            range = doc.Range()
            range.Text = TextBox1.Text
            doc.Activate()
            doc.CheckSpelling()
            Dim chars() As Char = {CType(vbCr, Char), CType(vbLf, Char)}
            TextBox1.Text = doc.Range().Text.Trim(chars)
            doc.Close(SaveChanges:=False)
            wordApp.Quit()
        End If
    End Sub
End Class




希望它有所帮助!


Hope it helps!

最好的问候,

Stanly


这篇关于Windows窗体中的拼写检查类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆