我有一个富文本字符/标记字符串,我想将它提供给代码中的richtextbox。如何将一个RTF字符串提供给一个richtextbox控件
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);
没有奏效。
任何人都可以给我几个sugestions。
BTW富文本来自从写字板保存,用记事本打开该文件,并使用该文本在建立我的字符串
+1注意到空间 – 2010-04-08 17:51:17