は自分の質問に答えるために:小さな変更(段落を追加しました)私たちのアプリケーションサーバーで。
私はこの場合、完全な "doc.RTF"ドキュメントを使用し、それをメモリストリーム/文字列としてインポートし、その値に必要な更新を適用することでこれを解決しました。
すなわちVBです。ネットスニペットの例
Using uStream = Assembly.GetExecutingAssembly.GetManifestResourceStream("Resourcefilepath.rtf")
Using mStream As system.IO.MemoeryStream = New MemoryStream()
uStream.CopyTo(mStream)
rtfstring = Encoding.UTF8.GetSTring(mStream.toArray())
'--Do the updates to the needed string as needed:
rtfstring.Replace("Value","UpdatedValue")
'--Load Property Memory String this method is returnind
RTFDataProperty = New MemoryStream(Encoding.UTF8.GetBytes(rtfstring))
End Using
End Using
次に、そのメモリストリームをDataFormats.Rtfとしてロードしました。
RichTextBox1.SelectAll()
RichTextBox1.Selection.Load(ClassName.RTFDataProperty, DataFormats.Rtf)
これは、そのドキュメントの書式設定とレイアウト用のテンプレートです。 (通常の練習の場合のシナリオの詳細ではなく)
私もそうここに始まる選択を適用したかったことは、私がやったことです:
'--Get my RichTextBox Text
rtbtext As String = New TextRange(RichTextBox1.Document.contentStart, RichTextbox1.Document.ContentEnd).Text
Dim strStartSelection As String = "Comments..."
Dim startTP As TextPointer
Dim endTP As TextPointer
'--Loop through the paragraphs of the richtextbox for my needed selection starting point:
For Each para As Paragraph In RichTextBox1.Document.Blocks
Dim paraText As String = New TextRange(para.ContentStart, para.ContentEnd).Text
If paraText = "" Then
Dim pos As TextPointer = para.ContentStart
startTP = pos
endTP = startTP.GetPositionAtOffset("".Length + 3) '--my string had ... on the end so had to add for avoiding the escape of that on length
RichTextBox1.Selection.Select(startTP, endTP)
RichTextBox1.Focus()
Exit For
End If
Next
これは、簡単なVB.netコードのレイアウトですが、それが有用であると分かったら、そこから単純化して調整することができます。 XamlReader.Loadが割り当てられていないストリーム、XamlReader、またはXmlReaderのを取るよう
おかげ
上記の提案は動作しません。 –