Tuesday, 30 October 2018

colors - How to colorize specific strings in powershell textbox

How to colorize specific strings in text box in powershell forms. I don't use any "studio" applications.


Output for example:


Searching...
a - found
b - Not found
c - found

Expected result:


Searching...
a - found
b - \red\Not found\red\
c - found

I heard about RichTextBox, but when using the code bellow it doesn't print anything, just an empty string(no errors appeared from code)


$StatisticsBox = New-Object System.Windows.Forms.RichTextBox 
$StatisticsBox.Location = New-Object System.Drawing.Size(170,30)
$StatisticsBox.Size = New-Object System.Drawing.Size(150,320)
$StatisticsBox.MultiLine = $True
$StatisticsBox.ScrollBars = "Vertical"
$StatisticsBox.ReadOnly=$True
$Form.Controls.Add($StatisticsBox)

$StatisticsBox.SelectionColor = 'red' <---- also tried "color.red"
$StatisticsBox.text = "`r`nNot Found:`r`n" + $StatisticsBox.AppendText("colored stirng") + "`r`n" +$StatisticsBox.text

No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...