更改文本框中文本的前色和底色 [英] Changing the forecolor and backcolor of text in a textbox
问题描述
我正在使用VB.NET制作C ++代码编辑器应用程序.我想在用户键入关键字时更改关键字的颜色.另外,我正在寻找一种突出显示代码行的方法.
I'm making a C++ code editor application using VB.NET. I'd like to change the color of the keywords as the user types it. Also I'm looking for a way to highlight some lines of the code.
是否可以更改文本框或富文本框中的一段文本的前色和背景色?
Is there a way to change the forecolor and backcolour of a piece of text inside a textbox or a rich textbox?
推荐答案
我真的不知道您想要做什么,这里有一些选择.
I do not really know what you want to do so here are some options.
如果您想获得有关如何编写语法突出显示控件的分步教程,可以阅读以下文章:
If you want a step by step tutorial on how to write a syntax highlighting control, you can read these articles:
- Syntax Highlighting in RichTextBox Part 1 and Part 2.
- Syntax Highlighting in RichTextBox using C#
有关用VB.NET编写的基本语法突出显示控件,请参见此文章:颜色语法控件(VB.NET).
For a basic syntax highlighting control written in VB.NET, see this article: Color Syntax Control (VB.NET).
如果要使用完整的语法突出显示控件,有两个非常好的选择.这些是:
There are two very good options if you want a fully-fledged syntax highlighting control. These are:
- ScintillaNET 用于WinForms;以及
- AvalonEdit for WPF.
- 在使用AvalonEdit 上有一个教程,因此一定要检查一下.
- ScintillaNET for WinForms and;
- AvalonEdit for WPF.
- There is a tutorial on Using AvalonEdit on CodeProject so be sure to check that out as well.
这篇关于更改文本框中文本的前色和底色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!