P.Brian.Mackey
P.Brian.Mackey

Reputation: 44295

How to append trow to richtextbox?

I get an Error "File Format is not valid" when I append RTF to a richtextbox

        public void Go()
        {
            rtb.Text = "Activated Partial Thromboplastin Time : Collected: 8/17/2012 9:06:00 AM\n";

            rtb.Select(rtb.TextLength, 0);//sets the selection starting point as the end of this Rtb
            rtb.SelectedRtf = @"{\trowd" +//ERROR thrown here
@"\cellx4000" +
@"\cellx9500" +
@"\intbl Activated Partial Thromboplastin Time\cell" +
@"\intbl 34.8 Seconds\cell" +
@"\row}";
}

How can I append a trowd to my RichTextBox?

Upvotes: 1

Views: 928

Answers (1)

LarsTech
LarsTech

Reputation: 81675

To insert your rtf code, it has to be a fully independent rtf document, which means you need the \rtf1{ header and a closing } symbol to your text:

rtb.SelectedRtf = @"{\rtf1\ansi{\trowd" +//ERROR thrown here
@"\cellx4000" +
@"\cellx9500" +
@"\intbl Activated Partial Thromboplastin Time\cell" +
@"\intbl 34.8 Seconds\cell" +
@"\row}}";

Do note the beginning of the string and also the extra } bracket at the end.

Upvotes: 2

Related Questions