我有一個富文本字符/標記字符串,我想將它提供給代碼中的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