Results 1 to 3 of 3

Thread: [RESOLVED] [2005] RichTextBox and StatusStrip

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    41

    Resolved [RESOLVED] [2005] RichTextBox and StatusStrip

    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?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: [2005] RichTextBox and StatusStrip

    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.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: [2005] RichTextBox and StatusStrip

    A little poking around the intellisense got this:
    VB Code:
    1. Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.SelectionChanged
    2.         Dim currentLine As Integer = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart)
    3.         Dim currentPositionInLine As Integer = RichTextBox1.SelectionStart - RichTextBox1.GetFirstCharIndexOfCurrentLine
    4.         ToolStripStatusLabel1.Text = String.Format("Line: {0}, Position {1}", currentLine, currentPositionInLine)
    5.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width