Reputation: 4319
I want to display the content of an RTF file in a Powershell RichTextBox.
I am trying to make a kind of custom EULA, and the easiest way to do it would be to write the content in an RTF file and then have it display in a RichTextBox on my form, so the user has to click a checkbox to accept it.
(I'm sure this sits between ServerFault and StackOverflow, but I'm guessing the DotNet gurus on here will know best. ;-) )
Cheers,
Ben
Upvotes: 0
Views: 4581
Reputation: 14722
In case anyone else happens upon this wondering where the PowerShell RichTextBox control came from it's a reference to the one in System.Windows.Forms. Here's the code with prerequisite build up:
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$rtb = New-Object System.Windows.Forms.RichTextBox
$rtb.LoadFile($path)
Upvotes: 4
Reputation: 4319
OK - that was easy. Should have got my lazy ass on Google a bit more before posting. Used RichTextFile.Loadfile(c:\myfile.rtf)
and it worked a treat.
Upvotes: 1