Set RTF text into WPF RichTextBox control

Do you really have to start with a string?

One method to load RTF is this:

rtfBox.Selection.Load(myStream, DataFormats.Rtf);

You probably should call SelectAll() before that if you want to replace existing text.

So, worst case, you’ll have to write your string to a MemoryStream and then feed that stream to the Load() method. Don’t forget to Position=0 in between.

But I’m waiting to see somebody to come up with something more elegant.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)