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 using Rtf.Replace()..

Problem using Rtf.Replace()..

Scheduled Pinned Locked Moved C#
help
3 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.
  • M Offline
    M Offline
    madhan_mss
    wrote on last edited by
    #1

    Hi, I have a rich text box names "Rtb" with the text "font". when i try to replace the text "font" with some other text, say "Text" using the below code, Rtb.Rtf = Rtb.Rtf.Replace("font", "Text"); the replaced text comes like "Microsoft Sans Serif;Text" rather than "Text". Any idea why it is behaving like this and a solution to fix this is welcome.

    G 1 Reply Last reply
    0
    • M madhan_mss

      Hi, I have a rich text box names "Rtb" with the text "font". when i try to replace the text "font" with some other text, say "Text" using the below code, Rtb.Rtf = Rtb.Rtf.Replace("font", "Text"); the replaced text comes like "Microsoft Sans Serif;Text" rather than "Text". Any idea why it is behaving like this and a solution to fix this is welcome.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Because you are treating the formatted text as if it was just text. Your replacement conflicts with the formatting in the string. What you see is broken formatting spilling into the text.

      --- Year happy = new Year(2007);

      M 1 Reply Last reply
      0
      • G Guffa

        Because you are treating the formatted text as if it was just text. Your replacement conflicts with the formatting in the string. What you see is broken formatting spilling into the text.

        --- Year happy = new Year(2007);

        M Offline
        M Offline
        madhan_mss
        wrote on last edited by
        #3

        Hi, Thanks for the reply. I am doing that to maintain the format of the replaced text. Is there any other way to do the same?

        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