Share via


How to format some text in a Richtext box - Powershell

Question

Monday, December 5, 2016 10:36 AM

Hi All

Currently i am working on powershell script using Forms.

I have a richtext box with some text. My requirement is format the text with in it like heading and body.

Below is my script for richtext box. In this i want the 'Read Me' to be bold; where as other texts to be in a different color and formating.

Please advice if i can format the text in the RichText box.

    $richtextBox1.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 400
    $System_Drawing_Size.Height = 243
    $richtextBox1.Size = $System_Drawing_Size
    $richtextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
    $richtextBox1.Name = "richtextBox1"
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 265
    $System_Drawing_Point.Y = 7
    $richtextBox1.Location = $System_Drawing_Point
    $richtextBox1.TabIndex = 0
    $richtextBox1.ForeColor = "Blue"
    $richtextBox1.Text = "READ ME`n`n1.Item one`n2. Item two"
    $form1.Controls.Add($richtextBox1)

Thank you

Regards

Ramesh

Regards Ram

All replies (2)

Tuesday, December 6, 2016 9:06 AM ✅Answered

The below link helped me.

http://stackoverflow.com/questions/27857230/powershell-net-bold-text-in-a-textbox

Regards Ram


Monday, December 5, 2016 5:22 PM

RTF is a specification for formatting text.  You can use RTF commands or you can use method calls to set font and color.

Search Web for examples of using rich text.

\(ツ)_/