Custom text edit control - where to start?

N

Nick Haines

I need to write my own custom text edit control.. but I'm not sure where to
start - I've never written a custom control... the features I want are
somewhat similar to the VS .Net text editor - text colouring, collapsible
regions etc... I haven't been able to find anything that could achieve that
which is free...

So what is the suggested starting point? Can I make some kind of control
that derives from a RichEdit box and write my own paint methods? Should I
build a completely custom user control? Any suggestions, or pointers to
example source code of similar controls would be appreciated!
 
V

Vijaye Rajji

It's not that simple to write a text editor like VS.

Basically, you'll have to implement your very own text buffer and position
tracking system. This should also be able to break big blobs of text into
manageable chunks/entities like lines, words, etc.

You could do all that or you can over-ride RichTextBox and do some clever
tricks with KeyDown/KeyPress and TextChanged events to parse the word which
is currently being edited and set its color, etc. But you'll soon find out
this is not a very good approach..

-vJ
 
J

Jason DeFontes

You might want to check out SharpDevelop. It's an open source IDE
written in C#. You might be able to glean some information from looking
at how their editor component is implemented.

http://www.icsharpcode.net/OpenSource/SD/

The book they advertise on their site provides some good explanations of
how the code works, including an extended discussion of different
approaches to writing text editors. I spent an afternoon reading through
it at Borders and found it quite interesting.

-Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top