I’m trying to implement scrolling functionality in a textBox, so that I’m only displaying as many lines as will fit on the viewable part of the textbox and discarding any other lines.
I have tried getting actualHeight and dividing it by the fontsize but this gives a line count which is too high so I display too many lines and the text is written off the end of the textBox which then increases actualHeight and so it continues forever.
I also tried using a textBox instead and using LineCount and GetLastVisibleLineIndex() but they both return -1.
Is there any easier way, short of writing a custom control something like this, which will allow me to get or calculate an accurate line count?
just set
TextWrappingtoWrapandVerticalScrollBarVisibilitytoAuto. If you want horizontal scrollbars too just setHorizontalScrollBarVisibilityaccordingly.UPDATE: To achieve the desired terminal like effet you could just append new text to the end of the TextBox and scroll down to the end after each append.