Load String into RichTextBox


I fail at finding a way to Load a String that is NOT coming from a File into a new Instance of an RichTextBox. Specifically, the Text is coming from an Excel-Sheet, that contains RTF-formatted Text.

There is the LoadFile-Method for loading Files into a RichTextBox, that is overloaded for use with Streams:

LoadFile(Stream, RichTextBoxStreamType)

My Progress so far:

$rtb = New-Object System.Windows.Forms.RichTextBox
$rtb.LoadFile($Worksheet.Cells.Item(1,9).Text, [System.Windows.Forms.RichTextBoxStreamType]::RichText)

Is this the right way to do it? Am I heading in the wrong direction?

Any Help is greatly appreciated!

Show source
| excel-vba   | powershell   | richtextbox   2017-01-04 22:01 1 Answers

Answers to Load String into RichTextBox ( 1 )

  1. 2017-01-04 23:01

    The RichTextBox class has a property Rtf. When constructing a new instance of the RichTextBox, you could set the Rtf property by using the -property parameter of New-Object:

    $rtb = New-Object System.Windows.Forms.RichTextBox -property @{
        rtf = $Worksheet.Cells.Item(1,9).Text 

Leave a reply to - Load String into RichTextBox

◀ Go back