I have a RichTextBox in vb.net which shows data from a .txt file using the "ReadAllText" methode.
As this program is running on a device with a touchscreen, i want to use "big", real buttons to scroll up and down rather than a scrollbar.
So i made a "scroll up" and "scroll down" button. The scroll down button is supposed to scroll down 4 lines from the last visible one. So if the Textbox looks like this:
1
2
3
4
5
6
7
8
9
10
i am seeing
1
2
3
4
5
due to the size of the textbox and i click the "scroll down" button, it should now scroll down 3 lines. So i should be seeing
5
6
7
8
9
however i can't seem to make it work like this.
This is what my code looks like currently:
Dim lastVisibleLine As Integer = RichTextBox1.GetLineFromCharIndex(RichTextBox1.GetCharIndexFromPosition(New Point(0, RichTextBox1.Height)))
Dim scrollToLine As Integer = lastVisibleLine + 4
Dim charIndex As Integer = RichTextBox1.GetFirstCharIndexFromLine(scrollToLine)
If charIndex >= 0 Then
RichTextBox1.SelectionStart = charIndex
RichTextBox1.ScrollToCaret()
End If
however if i currently see lines 1-5 in the textbox, this makes it jump straight to 10-15.
Can anyone help me?