How can I change the color of text which is displayed in a text box after a button is pressed?

79 Views Asked by At

On my C# code when the compile button is pressed, it displays a Success message in a text box but i want different lines of the text to be different colors. How can I do that? I'm using .NET Framework 4.7.2 The textbox used is a "RichTextBox"

enter image description here

CompileLogTB.Text = CompileLogTB.Text + Environment.NewLine + "[+]Successfully compiled file!" + Environment.NewLine + "[+]Task has been completed." + Environment.NewLine + "[+]You may now check the folder" + Environment.NewLine +  "this application is located for the output." + Environment.NewLine + "Comipled In 34ms!";

return;

1

There are 1 best solutions below

0
Zayar Linn On

Try with this:

richTextBox1.ForeColor = Color.Red; //color what you want.