troubleshooting Question

RichTextBox - Setting Font and Copying RTF Not Working

Avatar of Clif
ClifFlag for United States of America asked on
Visual Basic.NET
28 Comments3 Solutions856 ViewsLast Modified:
I have an application that contains a RTB where I allow the user (through a button) the ability to bold selected text.

The code to bold is this:
Private Sub btnBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBold.Click
    rtbComments.SelectionFont = New Font(rtbComments.SelectionFont.FontFamily, rtbComments.Font.Size, rtbComments.SelectionFont.Style Xor FontStyle.Bold)
End Sub

Later on in the code, I pass the RTF value in the RTB to an instance of an RTB in a class like this:
Private m_rtbTarget As New RichTextBox
Public WriteOnly Property rtbTarget() As RichTextBox Implements IReport.rtbTarget
    Set(ByVal value As RichTextBox)
        m_rtbTarget.Rtf = value.Rtf
    End Set
End Property

The problem is the bolded font isn't being passed.

If I paste text in the original RTB from a Word document, and it has bolded text, the bolding will be pasted as well.  Then, when the rtf is passed, the bolding does get passed as well, only the bolding that gets set with the button doesn't get passed.

What gives?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 28 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 28 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros