更改文本框中文本的前色和底色 [英] Changing the forecolor and backcolor of text in a textbox

查看:119
本文介绍了更改文本框中文本的前色和底色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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:

  1. RichTextBox第1部分中的语法突出显示使用C#在RichTextBox中语法突出显示
  1. Syntax Highlighting in RichTextBox Part 1 and Part 2.
  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:

  1. ScintillaNET 用于WinForms;以及
  2. AvalonEdit for WPF.
  1. ScintillaNET for WinForms and;
  2. AvalonEdit for WPF.
    • There is a tutorial on Using AvalonEdit on CodeProject so be sure to check that out as well.

这篇关于更改文本框中文本的前色和底色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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