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