How can I color text in a Rich Textbox in C#? [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-01 08:02:53

in your TextChanged Event handler

txtRichTextBox.Select(txtRichTextBox.Text.IndexOf("hi"), "hi".Length);
txtRichTextBox.SelectionColor = YourColor;
txtRichTextBox.SelectionFont = new Font("Times New Roman",FontStyle.Bold);

I remember doing something like this in Flex. We had to extend the richtextbox control, and make our own custom control, that would change the text color depending on what was being entered. We used data change events to achieve this. But my gut guess is you'll have to create a custom control to do this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!