Results 1 to 5 of 5

Thread: [RESOLVED] RichTextBox - Determine lines have changed

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [RESOLVED] RichTextBox - Determine lines have changed

    Hello everyone.

    I am working on a way to determine if the lines of a RichTextBox have changed.
    I currently use this code:
    Code:
                Dim newhash As Integer = Me.Text.GetHashCode
                If newhash <> Me._prevhash Then
                    Me._prevhash = newhash
                    Me._lines = MyBase.Lines
                    If Me._lines.Count = 0 Then
                        ReDim Me._lines(0)
                        Me._lines(0) = ""
                    End If
                End If
    But this method has a bad issue: The text property takes a while to "load up" plus getting its hash code adds to it. This code runs every time the Lines are needed (it is a property). So this code:
    Code:
    For i As Integer = 0 To Lines.Count - 1
        Dim line As String = Lines(i)
    Next
    Takes ages to complete, because for every line it checks if the lines have changed.

    I am trying to evade using MyBase.Lines too much, since that REALLY takes ages to load.

    - I can not use the modified property since it is unreliable (set to true if only a text color changes)
    - Can't use the RTF since it changes without the text changing (coloring) and the hash code is slow as well.
    - Can't use the TextChanged event, since it is sent after the SelectionChanged event (for some reason)

    Any help on this?

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