title: How do I set the Richtextbox.rtf to a rich text string?
body: <p>I am trying to add a header to the rich text in a RichTextBox, using VB.NET and Visual Studio 2017.  According to the documentation, Richtextbox.rtf should allow me to get or set the rich text including control codes.  However, I am unable to set *.rtf to a string containing rich text. I know that the rich text is correct because if I paste it into a *.rtf file, it is displayed correctly.</p>
  
  <p>The test code looks like this:</p>
  
  <pre><code>   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          Dim hdr As String = "{\header This is a header}"
          Dim s As String = RichTextBox1.Rtf
          s = s.Insert(s.LastIndexOf("}"c) - 1, hdr)
          MsgBox(s)
          With RichTextBox1
              RichTextBox1.Rtf = s
              MsgBox(RichTextBox1.Rtf)
          End With
      End Sub
  </code></pre>
  
  <p>The string s is correctly formatted as rich text, but RichTextBox1.Rtf is unchanged after the assignment.  What am I missing?  If I can't assign RichTextBox1.Rtf this way, is there an alternative?  </p>