By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,163 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,163 IT Pros & Developers. It's quick & easy.

Line Numbers in RichTextBox..

P: n/a
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.

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Adam Eavy via DotNetMonster.com" <fo***@DotNetMonster.com> schrieb:
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/>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
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

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #3

P: n/a
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:
sp***@dowco.com,cm*****@fuelindustries.com

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.