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