Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the forecolor and backcolor of text in a textbox

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?

like image 500
Arjun Vasudevan Avatar asked Oct 20 '10 03:10

Arjun Vasudevan


People also ask

Can you change the color and size of a text box?

Select the shape or text box. On the Drawing Tools Format tab, click Shape Fill > More Fill Colors. In the Colors box, either click the color you want on the Standard tab, or mix your own color on the Custom tab. Custom colors and colors on the Standard tab aren't updated if you later change the document theme.

Which is used to change the color of text?

Select the text that you want to change. On the Home tab, in the Font group, choose the arrow next to Font Color, and then select a color. You can also use the formatting options on the Mini toolbar to quickly format text.


1 Answers

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. Syntax Highlighting in RichTextBox Part 1 and Part 2.
  2. Syntax Highlighting in RichTextBox using C#


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 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.
like image 127
Alex Essilfie Avatar answered Sep 30 '22 06:09

Alex Essilfie