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. Problem with RichTextBox SelectedRtf

Problem with RichTextBox SelectedRtf

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Abisodun
    wrote on last edited by
    #1

    I'm having difficulty adding hidden text to a RichTextBox. See case2 below. Case1: Initialize Form1 in Main(string[] args){}. In Form1, initialize a RichTextBox as follows: RichTextBox rtb = new RichTextBox(); Observe that rtb.SelectedRtf is initially set to "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n"; Now try: rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}"; result: rtb.Text = "visibleTexthiddenText" as expected. Case2: Form1 is initialized as an MDIChild Form: Again in Form1, initialize a RichTextBox as follows: RichTextBox rtb = new RichTextBox(); This time rtb.SelectedRtf is initially set to empty string. Try: rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}"; result: rtb.Text = "visibleText" i.e. the hidden text is not being updated when Form1 is an MDIChild. Anyone know the cause/walkaround? Your help is appreciated. Thanks, B

    A 1 Reply Last reply
    0
    • A Abisodun

      I'm having difficulty adding hidden text to a RichTextBox. See case2 below. Case1: Initialize Form1 in Main(string[] args){}. In Form1, initialize a RichTextBox as follows: RichTextBox rtb = new RichTextBox(); Observe that rtb.SelectedRtf is initially set to "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n"; Now try: rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}"; result: rtb.Text = "visibleTexthiddenText" as expected. Case2: Form1 is initialized as an MDIChild Form: Again in Form1, initialize a RichTextBox as follows: RichTextBox rtb = new RichTextBox(); This time rtb.SelectedRtf is initially set to empty string. Try: rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}"; result: rtb.Text = "visibleText" i.e. the hidden text is not being updated when Form1 is an MDIChild. Anyone know the cause/walkaround? Your help is appreciated. Thanks, B

      A Offline
      A Offline
      Apemania
      wrote on last edited by
      #2

      I am facing the same issue. Its been 5 years since you have asked this question. Did you get the solution ? If so, please share with me.

      A 1 Reply Last reply
      0
      • A Apemania

        I am facing the same issue. Its been 5 years since you have asked this question. Did you get the solution ? If so, please share with me.

        A Offline
        A Offline
        Abisodun
        wrote on last edited by
        #3

        As I recall an external component was loading a different version of the riched32.dll/riched20dll. Workaround was to initialize the right dll first (new RichTextBox() in your application). Hope this helps.

        A 1 Reply Last reply
        0
        • A Abisodun

          As I recall an external component was loading a different version of the riched32.dll/riched20dll. Workaround was to initialize the right dll first (new RichTextBox() in your application). Hope this helps.

          A Offline
          A Offline
          Apemania
          wrote on last edited by
          #4

          Thank you very much for responding. I will give a try. Thanks again !

          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