I’ve got to do some special things with a RichTextBox. I have to add syntax highlighting and I need to be able to find out what character was added/removed/inserted at what position every time a key is pressed. Is there some way to edit the existing, or is there a open source (.net compatible, preferably VB.net) available for download? I’ve tried making my own, the problem is, it has to have every function normally available and I don’t have enough time to implement all of that.
Thanks!
There’s no need to reinvent the wheel here. You have two options for doing this. The first is that you can hook into the events raised by your RichTextBox and do what you need there:
There are a few issues with this. If you have to use the functionality in a lot of forms, you start duplicating code everywhere. You’ll also need some helper variables to track this data.
A better solution would be to create your own RichTextBox class. Obviously you don’t want to have to start again from scratch, so you can instead inherit from the existing class and then extend it how you want.
Once you’ve compiled MyRichTextBox, it should show up on the Toolbox tab and then you can drag & drop it onto your form.