如何在TRichEdit中更改某些字符的颜色? [英] How can I change the color of certain characters in a TRichEdit?

查看:276
本文介绍了如何在TRichEdit中更改某些字符的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个Delphi 7项目,我必须让用户输入一个数字(层下降)来构建圣诞树,但是我还需要将输出显示为 * (星号)。我在编辑TRichEdit中的某些星星行时遇到问题,以使颜色随机变化,就像真实的圣诞树一样。

I'm doing a Delphi 7 project where I have to let a user enter in a number (Layers going down) to build a Christmas tree, but I also need to display the output as * (stars). I am having a problem editing a certain line of stars in the TRichEdit to make the color change randomly just like a real Christmas tree shines.

推荐答案

在丰富的编辑控件中设置格式的工作方式是先选择文本,然后将格式应用于该选择。

Formatting in rich edit controls works by first selecting text, then applying formatting to that selection.

使用 SelStart SelLength 属性。

Select the text with the SelStart and SelLength properties.

使用 SelAttributes 属性,例如 SelAttributes.Color:= clRed;

这篇关于如何在TRichEdit中更改某些字符的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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