Hello everyone.
I am working on a way to determine if the lines of a RichTextBox have changed.
I currently use this code:
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: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
Takes ages to complete, because for every line it checks if the lines have changed.Code:For i As Integer = 0 To Lines.Count - 1 Dim line As String = Lines(i) Next
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?![]()




Reply With Quote