

Now, our wrong word(s) are underlined in Richtextbox. In Richtextbox, if we want to change the format for a specific area, we need to change the selected text only. Once the word is verified against Word's spell check functionality, if it is wrong then underline the word as a wrong word. Me.SelectionStart = Me.SelectionStart + Me.SelectionLength + 1 Me.Refresh() Me.SelectionFont.Size, FontStyle.Underline) Me.SelectionFont = New Font( Me.SelectionFont.FontFamily, _ (m_strRecentWord) = True) Then Me.SelectionStart = m_intLastIndex + 1 Me.SelectionLength = m_intLength If (m_strRecentWord.Length > 0 And IsWrongWord_ M_strRecentWord = Me.Text.Substring(m_intLastIndex + 1, m_intLength) ( 0, Me.SelectionStart - 1).LastIndexOf( " ")ĭim m_intLength As Integer = Me.SelectionStart - m_intLastIndex - 2 Me.SelectionFont.Size, FontStyle.Regular)Įnd If If (e.KeyValue = 32) Then Dim m_strRecentWord As String = String.Emptyĭim m_intLastIndex As Integer = Me.Text.Substring_ Add as I mentioned above, use RichTextBox as the base class.Ĭopy Code If ( Me.Text.Length = 0) Then Me.SelectionFont = New Font( Me.SelectionFont.FontFamily, _ So, add class (.vb) file under the solution. We are going to create a control which will incorporate the functionality. Step 1: Add a new Class file under solution If you want to create a user control to incorporate this functionality, you must user Richtextbox as the base class, since we are going to implement spell check functionality in Richtextbox. To implement spell check functionality, you can write code directly on Form or you can create user control. Once the user will select the option from the menu, it will be replaced with the right word. And when the user right clicks on the underlined wrong word, user will see the menu with available options for that wrong word. If it is wrong, that word will be underlined. When the user starts to type in the textbox and presses the spacebar, our functionality will check the last typed word against Word's spell check functionality to verify the word. This article will show you how to use Word's spell check functionality and underline the wrong word in the textbox. But, the main requirement was that it should be achieved using Microsoft's Word Interop. I got the main idea to write this article when I was coding for one project and we were in need of a textbox which can check the spelling and it can underline the wrong word.

It's very hard when we are coding for some project and we require the functionality that we can think of for each part, but if we try to think of them together, we just can't logically arrange the parts.
