Underline Only the Last Word in Richtextbox

ryoka012

Active member
Joined
Oct 13, 2011
Messages
32
Programming Experience
Beginner
Hi Expert,


I have a problem in creating an underline for my last word in Richtextbox.

Can any one guide me on this.

I am creating an application which the last word is being check on my database, it is like spelling check.


Using KeyDown event with

VB.NET:
if e.KeyCode = Keys.Space then
   'check the last word/value
   if lastword<>check to the database
        ' and create an underline for the last word. 
  end if
 end if


Thanks and best regards.
 

ryoka012

Active member
Joined
Oct 13, 2011
Messages
32
Programming Experience
Beginner
sorry for the trouble i have found the answer.

below is the code
Dim strSearch As String = richtextbox.text ' value of my last word
Dim index As Integer = RichTextBox1.Find(strSearch, 0, RichTextBoxFinds.WholeWord)


If index <> -1 Then
RichTextBox1.SelectionStart = index
RichTextBox1.SelectionLength = strSearch.Length
RichTextBox1.SelectionFont = New Font("Courier New", 15, FontStyle.Underline)
End If

https://social.msdn.microsoft.com/F...-a-perticular-string-in-vbnet?forum=vbgeneral
 
Top Bottom