Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RichTextBox.Rtf property argument exception

RichTextBox.Rtf property argument exception

Scheduled Pinned Locked Moved C#
data-structuresxml
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    partyganger
    wrote on last edited by
    #1

    Hey all, I'm trying to programmatically fill RichTextBox's Rtf property, I have an Xml file thats built like CP breaks the XML, so here's a tree representation:

    Paragraphs
    Paragraph
    Header
    Content

    I then iterate through all paragraphs and if the header isn't empty, i add it like so: string rtbContent += "\b" + headerNode.InnerText + "\b0"; but when I set the RichTextBox's Rtf Property to rtbContent, it throws an ArgumentException stating the string is in the wrong format... Why, the Rtf property is a string, and so is my variable...

    L H 2 Replies Last reply
    0
    • P partyganger

      Hey all, I'm trying to programmatically fill RichTextBox's Rtf property, I have an Xml file thats built like CP breaks the XML, so here's a tree representation:

      Paragraphs
      Paragraph
      Header
      Content

      I then iterate through all paragraphs and if the header isn't empty, i add it like so: string rtbContent += "\b" + headerNode.InnerText + "\b0"; but when I set the RichTextBox's Rtf Property to rtbContent, it throws an ArgumentException stating the string is in the wrong format... Why, the Rtf property is a string, and so is my variable...

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      You probably do not have the entire text wrapped with RTF formatting strings. For example, below is just a string of text typed into wordpad then viewed in Notepad.

      {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
      {\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 This is RTF text\par
      }

      1 Reply Last reply
      0
      • P partyganger

        Hey all, I'm trying to programmatically fill RichTextBox's Rtf property, I have an Xml file thats built like CP breaks the XML, so here's a tree representation:

        Paragraphs
        Paragraph
        Header
        Content

        I then iterate through all paragraphs and if the header isn't empty, i add it like so: string rtbContent += "\b" + headerNode.InnerText + "\b0"; but when I set the RichTextBox's Rtf Property to rtbContent, it throws an ArgumentException stating the string is in the wrong format... Why, the Rtf property is a string, and so is my variable...

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        When assigning the Rtf property, you must include all necessary RTF information, including the RTF headers. See the RTF 1.6 Specification[^] on MSDN for more information.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups