Click here to Skip to main content
15,896,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys, I need some help.
I have a richTextbox and what I want to do is display somewhere inside my form the current line and column where the user is situated. Then considering the fact that the richTextBox is to be something like an A4 page, using the line value and font size and so on I want to somehow signal to the user the page he's on.
So? Any help please?
Posted
Updated 5-Aug-19 6:49am

Check out this[^] CodeProject article.
It seems that the control from the article does exactly what you need. :)
 
Share this answer
 
v3
Comments
Dalek Dave 13-Aug-10 11:02am    
Good Call
This might not be the best way to do it, but I played with it and it seems to work. If it's not quite what you were looking for it should at least get you started.

VB
Dim intLineNumber As Integer =  RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
Dim intCharIndexOfLine As Integer = RichTextBox1.GetFirstCharIndexOfCurrentLine()
Dim intCharIndex As Integer = RichTextBox1.SelectionStart
Dim intCol As Integer = Math.Abs(intCharIndexOfLine - intCharIndex)
 
Share this answer
 
Comments
Toli Cuturicu 14-Aug-10 11:18am    
Reason for my vote of 1
not c# (see tags)
Hedi X Majid 22-Nov-20 12:04pm    
To display use this:
Label1.Text = "Ln " + intLineNumber.ToString + ", Col " + intCol.ToString
C#
// Get current line index using char index of any selected text for that line
string CurrentLineIndex = richTextBox.GetLineFromCharIndex(richTextBox.SelectionStart);
// Get current line string from array of lines using the index
string CurrentLine = richTextBox.Lines[CurrentLineIndex]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900