vb.net富文本框,拼写检查,在右键单击上下文菜单中显示所选文本的建议,并替换为单击的所选菜单项

时间:2018-11-07 10:53:29

标签: vb.net menu richtextbox spell-checking right-click

我在vb.net中设计自定义拼写检查软件 我到达了以下代码

RichTextBox1.Text = RichTextBox1.Text & " "



    Dim lenoftxt As Integer
    Dim i As Integer
    Dim str As String
    Dim tillword As String



    tillword = ""
    str = ""

    i = 1

    If Not RichTextBox1.Text = "" Then
        lenoftxt = RichTextBox1.Text.Length
        '   MsgBox(lenoftxt)

        For i = 1 To lenoftxt
            str = Mid(RichTextBox1.Text, i, 1)

            ' MsgBox(str)

            If str = "ا" Or str = "ب" Or str = "ٻ" Or str = "ڀ" Or str = "ت" Or str = "ٿ" Or str = "ٽ" Or str = "ٺ" Or str = "ث" Or str = "پ" Or str = "ج" Or str = "ڄ" Or str = "ڃ" Or str = "چ" Or str = "ڇ" Or str = "ح" Or str = "خ" Or str = "د" Or str = "ڏ" Or str = "ڌ" Or str = "ڊ" Or str = "ڍ" Or str = "ذ" Or str = "ر" Or str = "ڙ" Or str = "ز" Or str = "س" Or str = "ش" Or str = "ص" Or str = "ض" Or str = "ط" Or str = "ظ" Or str = "ع" Or str = "غ" Or str = "ف" Or str = "ڦ" Or str = "ق" Or str = "ڪ" Or str = "ک" Or str = "گ" Or str = "ڳ" Or str = "ڱ" Or str = "ل" Or str = "م" Or str = "ن" Or str = "ڻ" Or str = "و" Or str = "ه" Or str = "ھ" Or str = "ي" Or str = "ئ" Or str = "آ" Or str = "۾" Or str = "۽" Or str = "ِ" Or str = "َ" Or str = "ُ" Or str = "ى" Then



                tillword = tillword & str

            Else



                romantranssql = "Select word from approved where word='" & tillword & "'"

                MsgBox(romantranssql)



                pth = My.Application.Info.DirectoryPath
                romantransconn.ConnectionString = "Provider=Microsoft.ace.oledb.12.0; Data Source=" & pth & "\database.mdb; User Id=admin; Password=;"
                romantransda = New OleDbDataAdapter(romantranssql, romantransconn)
                romantransds = New DataSet
                romantransda.Fill(romantransds, "DisplayCenterData")
                romantransdt = romantransds.Tables("DisplayCenterData")
                romantranscmb = New OleDbCommandBuilder(romantransda)



                If Me.BindingContext(romantransdt).Count >= 1 Then


                    MsgBox("record found - " & tillword)
                    tillword = ""

                End If
                If Me.BindingContext(romantransdt).Count <= 0 Then
                    Dim a As Integer
                    a = tillword.Length + 1


                    RichTextBox1.Select(i - a, tillword.Length)
                    ' MsgBox(RichTextBox1.SelectedText & " selected text, not found and red")
                    RichTextBox1.SelectionColor = System.Drawing.Color.Red
                    MsgBox(RichTextBox1.SelectedText & "-" & i - a & "-" & tillword.Length)



                    ListBox1.Items.Add(tillword)

                    txtnormalword.Text = tillword

                    '    Button5_Click_1(sender, New System.EventArgs())



                    tillword = ""






                End If



            End If
        Next
    End If


    '   tillword = ""

以上代码突出显示表中未包含的内容为错误 现在,我想右键单击突出显示的单词,右键单击选择它,并显示填充有列表框项目的右键单击菜单,然后在右键单击菜单中单击“替换”所选/突出显示的文本

我有一个列表框,其中显示了对richtextbox中的突出显示文本的更正(拼写错误)。

我想加载右键单击上下文菜单,例如

右键单击菜单.item .add(listbox.items)  请帮助

0 个答案:

没有答案