Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I have a string as "Hello World" in the RichTextBox. I am selecting the each word and applying style.In this string "Hello" is bold and having strike-Through.Suppose I want to apply underline to the complete Text (Hello world).The previous style for which the "Hello" has is removing and new style is appending.This is a migrated project to VB.NET when we do the same in VB6 it is working perfectly.It is not working in VB.NET.

VB
If richTb1.SelectionFont.Underline Then
            richTb1.SelectionFont = VB6.FontChangeUnderline(richTb1.SelectionFont, False)
Else
            richTb1.SelectionFont = VB6.FontChangeUnderline(richTb1.SelectionFont, True)
End If
Posted

1 solution

At last I had fixed the issue by restyling the text char by char .See my solution

VB
If rtfBox.SelectionFont.Bold Then
            For x As Integer = selectionStart To selectionEnd - 1
                rtfBox.Select(x, 1)
                rtfBox.SelectionFont = VB6.FontChangeBold(rtfBox.SelectionFont, False)
            Next
Else
            For x As Integer = selectionStart To selectionEnd - 1
                rtfBox.Select(x, 1)
                rtfBox.SelectionFont = VB6.FontChangeBold(rtfBox.SelectionFont, True)
            Next
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900