0

I have developed my own scripting language to query my datasource with some unique logic, I want to offerthis script to my users and would like to show it in a textbox where they can type the syntax and receive the feedback by the color of the text they are typing, so for example I want pretty much color-code like .net does, i.e. I want blue keywords, green comments etc..

What i want to ask, is if there is some way to color code my text without using 3rd parties components, especially if paid per use but in general terms I would prefer to use .net controls.

Ritardi.Net
  • 99
  • 2
  • 11
  • Customise the paint() event of your textbox? – Thomas Ayoub Nov 02 '15 at 15:18
  • 1
    Regex + richtextbox. Search "C# syntax highlight textbox" on google for examples on how to do it, you don't have to use the third party library, but you can at least look at examples. This site is not in an appropriate format for answering this question though, so I'm voting to close it as too broad. – Ron Beyer Nov 02 '15 at 15:24
  • @Thomas: What `Paint` event are you talking about??? No such thing in `TextBoxes` ! – TaW Nov 02 '15 at 15:28

1 Answers1

0

You can use the RichTextBox to for different colors.

RichTextbox Color

Jigneshk
  • 350
  • 1
  • 7
  • hello, thank you. it is cool that there is a control, I think that this will make it somehow possible. But this implies to have two boxes and color a whole line. While for my needs I have one single box (the editor) and the coloring should take place while typing, coloring keywords, variables and other elements accordingly to our logic. – Ritardi.Net Nov 02 '15 at 15:25
  • You can color each character as you please in a RTB. Don't start without learing the basics of it though!! – TaW Nov 02 '15 at 15:27
  • @Ritardi.Net , I gave you example link to understand the RichTextbox. You have to write logic while user typing. got it? – Jigneshk Nov 02 '15 at 15:34
  • @Jigneshk it clear, but you know what happens when you change the SelectedText property of a RTB while the user is typing? You can not change it as will stop the user in the best case, and in the worst case the user will type over the selected text and replace it. – Ritardi.Net Nov 02 '15 at 15:52
  • You need to create a colorMySkript function you call on each TextChanged event. It should 1) store the selection 2) do all the coloring 3) restore the selection if there was one. – TaW Nov 02 '15 at 16:30