如何更改文字颜色?
你好 我正在使用以下代码附加文本,我想更改新附加文本的颜色,这怎么可能
if (strMessage.IndexOf("pvt|") == -1)
{
string[] temp = strMessage.Split(new string[] {"&^:^&"}, tringSplitOptions.None);
strMessage = temp[0] + "(" + DateTime.Now.ToString("HH:mm tt") + ")" + ":" + emp[1];
txtLog.AppendText(strMessage + "\r\n");
}
请帮助..
Hi
I am using following code to append text and I want to change the color of newly appended text how is it possible
if (strMessage.IndexOf("pvt|") == -1)
{
string[] temp = strMessage.Split(new string[] {"&^:^&"}, tringSplitOptions.None);
strMessage = temp[0] + "(" + DateTime.Now.ToString("HH:mm tt") + ")" + ":" + emp[1];
txtLog.AppendText(strMessage + "\r\n");
}
Please help..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文本显示在哪里?它似乎转到
TextBox
,但这只是一个假设。更改普通文本框中各个文本块的颜色是不可能的。您可以通过设置 TextBox 的
ForeColor
属性来更改整个 TextBox 的前景色。要单独更改其中的各个部分,您将需要使用不同的文本框,例如 在这里回答。
Where is the text being displayed? It appears that it goes to a
TextBox
, but that's just an assumption.Changing the color of individual chunks of text within a normal TextBox is not possible. You can change the entire TextBox's forecolor by setting its
ForeColor
property.To change pieces of it individually, then you will need to use a different textbox, such as shown in the answer here.
假设 txtLog 是一个文本文件,您必须将 ascii 控制字符编码到流中,并有一个编辑器来读取它们。这个链接可能会有所帮助。
Assuming that txtLog is a text file you would have to encode ascii control characters into stream and have an editor that read them. This link might help.