Custom TextBox Control

rowanjl

Newcomer
Joined
Sep 21, 2005
Messages
7
I've been looking at creating an entire textbox from scratch that matches my needs, but I don't really know where to begin (apart from making a new User Control...). I've searched everywhere and been unable to find any information on making a textbox control.

Can anyone point me to some information?

And can someone explain how to give a control the normal BorderStyle property?

Thanks! :)
 
Creating your own control from scratch would be an awful lot of work if you are doing it properly, is there any reason why you couldn't inherit from Textbox and just add your own functionality or override existing methods to get the end result you desire?
 
Yeah, thats what I was planning to do, but I need to add syntax highlighting. Working with a RichTextBox is very slow, as I'm selecting the text and colouring it.

There must be a better way :(
 
Working with a RichTextBox is very slow
Then you must be doing something wrong. :) ;) Working with it shouldn't be any slower than a regular textbox. Can you be more specific in what the problems with it are?
 
Well, the highlighting I'm doing means I have to do the entire document every time the text changes, thats why its slow. Perhaps there is a better way?
 
I too tried to write my own text editor from scratch, back in my VB6 days. The problem was that there is very little information on something like this, and google doesn't help since you aren't really sure what exactly to look for.

After a while of on and off again work, porting code to VB.Net and then to C# (I do it in the spare time of my spare time) I have come close to completing it.

Anyway, I found that there are many different parts of a text editor, the user control being the last (yet very important) part of it.

First off, you have to decide how you are going to implement the data structures that will be containing the text. Read these pages about Text Editor Data Structures.

This and other structures which would describe the text (management of lines, undo stack, coloring, etc) would make up the underlying data part of the control.

I spent a good part of my time figuring this stuff out until I found out about Sharp Develop. While most of their source code is good, differing a little when it came to the data structure, it did probably shave off some time from my project (It is hard code to follow, but the data part of it is well structured unlike the GUI part of it which is, imo and to put simply, awful).

It is a long road to travel on, but probably a lot shorter if you dedicate more time and effort than I did, and you'll be a better programmer for it.
 
Back
Top