Change color in output to TextBox depending on error or not

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
twp111
Posts: 4
Last visit: Thu Jul 03, 2014 1:09 pm

Change color in output to TextBox depending on error or not

Post by twp111 »

Hi,
I'm new to GUI-powershell scripts. Have made a GUI in Primal Forms for an AD-script I use to handle group-members. I log what happens to a TextBox ($LogBox). Now I would like to change the color of the log dependin if I get an error or not.

Have tried to search this forum and google it but cant find anything that would help me.

I can change color of everything in the textbox with $LogBox.forecolor = "red" but that is not what i want. I just want to change specific lines in the textbox. Not everything!

ex:
PowerShell Code
Double-click the code block to select all.
$LogBox.AppendText("***Error! Conputer: $Computer could not be found i AD"+[char]13+[char]10)
Can anyone please help me with an example of how to make the line above be written in RED?
User avatar
boyddt_co
Posts: 89
Last visit: Mon Sep 25, 2023 9:36 pm

Re: Change color in output to TextBox depending on error or

Post by boyddt_co »

I'm running into the same issue and it appears that the text box sees all text as the same, more or less like Notepad. I'm still sorting things out but it looks like I'll be creating a large number of smaller text boxes so that I can manipulate the text individually based on current status.
User avatar
twp111
Posts: 4
Last visit: Thu Jul 03, 2014 1:09 pm

Re: Change color in output to TextBox depending on error or

Post by twp111 »

boyddt_co wrote:I'm running into the same issue and it appears that the text box sees all text as the same, more or less like Notepad. I'm still sorting things out but it looks like I'll be creating a large number of smaller text boxes so that I can manipulate the text individually based on current status.
Hm, that doesn't sound good. Im pretty shore that I have seen it done but can't find the scrip. Mabe it wasn't primal forms. How about I you try the richtextbox or whatever it's name is? There have to be a solution to this! :)
This topic is 9 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked