0

I've been wondering how do I do that if I type "Hello" to textbox, it's color will be set to yellow, however if I type "GoodBoy" that specific word will get red.

Is there a way in C# WinForms how to set a color of specific words in textbox whenever you type them. I only know how to change the textbox font color but that always sets the color of all characters in that textbox, so is there a way to set color of a word individually?

Thank you for help.

  • You should look in to [RichTextBox Class](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.richtextbox?view=windowsdesktop-6.0) and [Format text in Rich Text Box](https://stackoverflow.com/questions/4077582/format-text-in-rich-text-box) – JayV Jun 11 '22 at 19:36
  • 1
    [How to color different words with different colors in a RichTextBox while a user is writing and raise an event when that colored text is clicked](https://stackoverflow.com/a/48358496/7444103) – Jimi Jun 11 '22 at 19:43

1 Answers1

1

I didn't used C# WinForms for a while, but as I remember you have object aka RichTextBox which allows you to do more things (and use more then one style for your text).

You will find more info in this link: RichTextBox.SelectedText

Good luck

Lee G
  • 84
  • 2