I am wanting to show in my status strip where my cursor is currently located in a RichTextBox. For example 3:10 would be the 3rd line and the 10th character.
Anyone know how to make something like this?
Printable View
I am wanting to show in my status strip where my cursor is currently located in a RichTextBox. For example 3:10 would be the 3rd line and the 10th character.
Anyone know how to make something like this?
You can use the SelectedChanged event of the RichTextBox to capture when the cursor changes then just write teh current position. you can get the index using SelectionStart but I'm not sure about the line or character. It can't be too hard though.
A little poking around the intellisense got this:
VB Code:
Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.SelectionChanged Dim currentLine As Integer = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) Dim currentPositionInLine As Integer = RichTextBox1.SelectionStart - RichTextBox1.GetFirstCharIndexOfCurrentLine ToolStripStatusLabel1.Text = String.Format("Line: {0}, Position {1}", currentLine, currentPositionInLine) End Sub