[Richtextbox].Rtf.Replace();

  • Thread starter Michael J Robinson
  • Start date
M

Michael J Robinson

Load richtextbox with a .rtf document. Want to use the
Rtf.Replace method to replace text, but nothing happens.
If anyone has suggestions it'll be greatly appreciated
Thanks - Michael
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

The reason this doesn't work is that the Replace method on the string
class will return a string where the Replace occurs. It does not modify the
original string. So, in order to perform the replace, you would have to do
this:

// Assume the textbox is named mobjRtf.
mobjRtf.Rtf = mobjRtf.Rtf.Replace("hello", "bye");

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top