【发布时间】:2010-04-09 01:17:02
【问题描述】:
我有一串富文本字符/令牌,我想将其提供给代码中的富文本框。
string rt = @" {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fnil\fprq2\fcharset0 Biondi;}}"+
@"{\colortbl ;\red255\green0\blue0;}"+
@"{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20\par"+
@"\cf1\f1 hello\cf0\f0 \ul world\par}";
我已经尝试过了:
System.IO.MemoryStream strm = new System.IO.MemoryStream();
byte[] b = Encoding.ASCII.GetBytes(rt);
strm.BeginRead(b, 0, b.Length, null, null);
richTextBox1.LoadFile(strm, RichTextBoxStreamType.RichText);
它没有工作。
谁能给我一些建议。
顺便说一句,富文本来自从写字板保存,用记事本打开文件并使用 in 来构建我的字符串
【问题讨论】: