Line Numbers in RichTextBox..

  • Thread starter Thread starter Adam Eavy via DotNetMonster.com
  • Start date Start date
A

Adam Eavy via DotNetMonster.com

Hi, could any1 kindly tell me how to implement line numbers with a rich
text box (im making my own scripting language and really need line numbers!)

Ive looked all over the net for over 4 days now and just cant find
anything. Ive found C# versions but these are no good, because Im only
familiar with VB.NET.

Any help would be very much appreciated.
 
Adam Eavy via DotNetMonster.com said:
Hi, could any1 kindly tell me how to implement line numbers with a rich
text box (im making my own scripting language and really need line
numbers!)

Ive looked all over the net for over 4 days now and just cant find
anything. Ive found C# versions but these are no good, because Im only
familiar with VB.NET.

If you have the C# code of a textbox which supports line numbers, you could
compile a C# class library and use this class library from your VB.NET EXE
application.

SharpDevelop contains an editor control written in C#:

SharpDevelop @ic#code
<URL:http://www.icsharpcode.com/OpenSource/SD/>

Commercial solutions:

Syncfusion: Essential Edit
<URL:http://www.syncfusion.com/products/product.aspx?p=3>

SyntaxEditor .NET Control
<URL:http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/>
 
Thanks for your reply

However, none of the C# Converters correctly convert the code (this
includes #Develop) and are causing errors that I cannot manage to find a
solution for.

Ive decided after all this time that Im going to have to attempt to battle
the problem with another solution, someone mentioned about using 2
RichTextBoxes.

So I have started trying it out, problem is this:

I have no trouble getting the f1rst RTB (the one with line numbers) to add
line numbers when the Return key is pressed in the second RTB, but I cannot
find a solution to determine when the user has removed a line (by pressing
backspace) and following this, I dont know how to remove the appropriate
line number!

Not sure if you could maybe help me with this, but Im starting to run out
of hair to pull out now! and would greatly appreciate any support

Many Thanks in advance
 
Don't bother implemeting 2 RTB's I've tried countless methods using this
approach and everytime there seems to be a new crop of bugs that arise from
it. The only relative suCcess I've had was using unmanaged code to sync
events for the RTB's.

BUT.

I ended up writing my own extended RTB control -- it DOES use unmanaged
code to modify the NCA (non client area) of the control to draw a gutter
for the line numbers. I'm currently using it in a project and it's stable,
the only drawback to the control is that once you start getting into files
with over 1,500 or so lines, performance really starts to crap out. This is
more a fault of the native RichTextBox contol that's been there since VB
Classic.

FYI: I've added some nice customization into the control such as:
1. line number font
2. line number color
3. gutter backcolor
4. gutter divider
5. current linenumber highlight forecolor
6. current linenumber backcolor

and a few other things too.

If you want, I would be willing to either sell you a copy of the control,
or do an exchange of some sort? email me:
(e-mail address removed),[email protected]
 
Back
Top