Click here to Skip to main content
15,845,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a editor like application which will highlight codes (syntax highlighting) and have auto complete feature for functions variables etc... I don't have any idea to do that. Can you please provide me some tutorial links or some tips about that? Can I implement these features in a "Rich Text Box"?

Note: I already read this article: Using ICSharpCode.TextEditor[^]. I don't want to use any external library or tools to do that.

Yes, it can be done using a RichTextBox. It is not easy, but it is definitely possible. Anyway, this question is way too complex to be answered in detail so I can only give you very general information.

You will have to track changes in the text box and parse the text after each key stroke to highlight the text. It might be tricky to make it work right and you will definitely run into performance problems. You will most probably need to use multiple threads to boost the performance a bit and to keep your application responsive.

As for auto-completing, it cannot be done directly in RichTextBox, but you can track all changes made to the text and, when necessary, display an auto-complete list in some kind of a child window.

I have written such application once and I remember I was not able to find any really good tutorial... However, I found several useful tips here and there, I'm sure you will find them too if you try a bit.
Share this answer
Chanchal Kumar Ghosh 18-Nov-10 3:27am    
Can you please provide me some links of tips here?
Kubajzz 18-Nov-10 5:36am    
I would have given you the links if I had them...
Look at the source code from that article. That should give you an idea of how it can be done. It will also show you that it is not a trivial task.

As for using a RichTextBox - no that is not a good place to start.

Share this answer
Chanchal Kumar Ghosh 18-Nov-10 3:26am    
This project is using an external library, I don't want to use that.
Nicholas Butler 18-Nov-10 4:37am    
The library is open source - I meant look at that! It will show you how much work is required to get what you want.
Hi Chanchal, I've implemented a simple syntax highlighting and auto-complete RichTextBox, and I used it in my code editor.
Check it out here. I hope it's helpful. Regards!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900