简单文本颜色在富文本框中

编程入门 行业动态 更新时间:2024-10-27 03:31:39
本文介绍了简单文本颜色在富文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

更多推荐

简单文本颜色在富文本框中

本文发布于:2023-06-09 04:09:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/594945.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   框中   颜色   简单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!