如何将trow追加到richtextbox?

时间:2012-12-19 19:07:31

标签: c# winforms richtextbox rtf

当我将RTF追加到"File Format is not valid"

时,我收到错误 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}";
}

如何将trowd附加到我的RichTextBox?

1 个答案:

答案 0 :(得分:2)

要插入rtf代码,它必须是完全独立的rtf文档,这意味着您的文本需要\rtf1{标题和结束}符号:

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

请注意字符串的开头以及末尾的额外}括号。