简单文本颜色在富文本框中 [英] simple text color in rich text box

查看:1058
本文介绍了简单文本颜色在富文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以找到一百万个例子来做一个富文本框应用语法高亮。但我需要它只是一个简单的方法来添加一个不同颜色的单词。

I can find a million examples of doing reg ex to apply syntax highlighting to a rich text box. but what i need it just a simple way to add in a word of a diffrent color.

代码是什么,只是把单词Hello World放入一个文本框中,Hello是红色的,世界是绿色的?

What would the code be to just put the words "Hello World" into a textbox and have Hello be red and World be green?

此代码无效。

this.richTextBox1.SelectionColor = Color.Red
this.richTextBox1.text += "Test"


推荐答案

例如:

richTextBox1.Text += "Test"
richTextBox1.Select(richTextBox1.TextLength - 4, 4)
richTextBox1.SelectionColor = Color.Red

这篇关于简单文本颜色在富文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆