如何更改按下按钮后文本框中显示的文本颜色?

问题描述 投票:0回答:1

在我的 C# 代码上,当按下编译按钮时,它会在文本框中显示成功消息,但我希望文本的不同行具有不同的颜色。我怎样才能做到这一点?我正在使用 .NET Framework 4.7.2 使用的文本框是“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!";

返回;

c# textbox textcolor
1个回答
0
投票

试试这个;

richTextBox1.ForeColor = Color.Red; //给你想要的颜色。

© www.soinside.com 2019 - 2024. All rights reserved.