0
votes


I'm working with Compact Framework and I'm trying to scroll in a TextField with a vertical scrollbar. The TextField contains four lines of text and only three of the four are actually displayed due to the TextField height. I want to scroll from the top to the bottom only to show the fourth or > fourth line. The only problem is, the scrollbar wont scroll at all.

Any suggestions?

TextField properties:
- height = 150
- scrollbar = Vertical
- wrapped = false
- multilines = true

Text is added while looping trough a string array and adding Environment.NewLine at the end of each string, except from the last string.

1

1 Answers

0
votes

I assume you mean a TextBox as there is not TextField control in the Compact Framework.

Scrolling to the end of the control is pretty simple:

public void ScrollToBottom(TextBox t)
{
    // move the caret to the end of the text
    t.SelectionStart = t.Text.Length - 1;
    t.SelectionLength = 0;
    // and scroll to the caret
    t.ScrollToCaret();
}