Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How can I set the color of text in a richtextbox?

Tags:

c#

richtextbox

I have a richtextbox in an app and I'd like key words to be in another color, how can I do this?

Thanks Jade

like image 864
Jade M Avatar asked Sep 07 '09 23:09

Jade M


People also ask

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is %d in C programming?

In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.

Why is C named so?

Because a and b and c , so it's name is C. C came out of Ken Thompson's Unix project at AT&T. He originally wrote Unix in assembly language. He wrote a language in assembly called B that ran on Unix, and was a subset of an existing language called BCPL.

What is full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.


1 Answers

you can use:

richTextBox1.SelectionColor = Color.Yellow;
richTextBox1.SelectionBackColor = Color.Blue;

to select a text set:

richTextBox1.SelectionStart = text_position_in_editor (caret position)

richTextBox1.SelectionLength = text_length

then set SelectionColor ... (see all properties starting with Selection...)

Or, you can set directly the Rtf property (or richTextBox1.SelectedRtf) which contains formatting info.

Type some text in WordPad, change it's formatting, copy and paste it into your RichTextBox, show the property Rtf value, you should be able to learn faster how to meet your needs.

like image 54
manji Avatar answered Sep 30 '22 14:09

manji