|
-
Jul 3rd, 2006, 10:33 PM
#1
Thread Starter
Addicted Member
[2005] number lines
can someone tell me how to number lines in a richtextbox just like vb?
like have line 1 line 2 and so on?
and how to make more numbers appear when the user hits enter?
-
Jul 3rd, 2006, 10:46 PM
#2
Re: [2005] number lines
I believe the syntax editor in Visual Studio is actually a highly modified treeview. Doing this in an actual RichTextBox is a bit more difficult.
I'd say use 2 RichTextBoxes and just add and remove numbers as needed from 1. Otherwise you're going to be either painting the RichTextBox yourself or doing some complex adding and removing numbers and adding/removing tabs to space everything apart.
-
Jul 3rd, 2006, 11:06 PM
#3
Thread Starter
Addicted Member
Re: [2005] number lines
o i thought it was textbox thats what it looks like.
so how would i do this in a treeview?
Last edited by jermaine; Jul 10th, 2006 at 11:41 PM.
Reason: hello
-
Jul 5th, 2006, 11:17 AM
#4
Addicted Member
Re: [2005] number lines
Something you can do is split it using vbcrlf, add number to front of each line and then join it back together.
-
Jul 5th, 2006, 11:55 AM
#5
Re: [2005] number lines
TextBox and RichTextBox have a lines property which you can loop through in order to loop through all lines of text that the control contains. In order to change this information, you can copy the info to a temp string array, modify the information, and then set the array back to the lines property of the control, like the example below. The below example should add sequential numbers to each line of text in a richtextbox control...
VB Code:
'String array containing richtextbox information
Dim TextLines() As String = RichTextBox1.Lines
'loops through temp string array, adding numbers to each index
For I As Integer = 1 To TextLines.GetUpperBound(0) + 1
TextLines(I - 1) = I.ToString & " : " & TextLines(I - 1)
Next
'assign the new modified string array to the lines property of the control
RichTextBox1.Lines = TextLines
Last edited by gigemboy; Jul 5th, 2006 at 12:08 PM.
Reason: Removed counter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|