I using C# windows forms and I have richtextbox and I want to color some text in red, some in green and some in black.
How to do so? Image attached.

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
System.Windows.Forms.RichTextBoxhas got a property of typeColorof the nameSelectionColorwhich gets or sets the text color of the current selection or insertion point. You can use this property to mark specific fields in yourRichTextBoxwith the colors you specify.Example
Notice that: You may avoid calculations by using
RichTextBox.Find(string str)which can be added throughObject Browserif you would like to highlight the text within theLinesinRichTextBoxgiving it’s valueExample
Thanks,
I hope you find this helpful 🙂