gpt4 book ai didi

vb.net - 富文本框中的简单文本颜色

转载 作者:行者123 更新时间:2023-12-03 18:21:20 26 4
gpt4 key购买 nike

我可以找到一百万个使用 reg ex 将语法突出显示应用于富文本框的示例。但我需要的只是一种简单的方法来添加不同颜色的单词。

将“Hello World”字样放入文本框中并让 Hello 为红色而 World 为绿色的代码是什么?

此代码不起作用。

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

最佳答案

此代码将红色文本“Hello”和绿色文本“World”添加到 RichTextBox。

RichTextBox1.SelectionColor = Color.Red
RichTextBox1.SelectedText = "Hello "
RichTextBox1.SelectionColor = Color.Green
RichTextBox1.SelectedText = "World"

关于vb.net - 富文本框中的简单文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1683779/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com