Multiline textbox and scrolling

  • Thread starter Thread starter Markus Humm
  • Start date Start date
M

Markus Humm

Hello,

how to scroll to the last line in a multiline textbox? ScrollTo doesn't
work as

- even if the textbox got it's focus via .focus first the cursor
was not in it
- I don't know how to programatically set the cursor to the end
of the text

Any hints?

Greetings

Markus
 
Bjørn Brox said:

Sorry tried it and didn't work for me. Obviously the caret wasn't in the
control or not at the end of it.

=> how to place the caret in this control and move it to the end of the
text? .Focus before it didn't seem to do the trick either. But: it could
also be some bug in the emulator used.

Which is the latest emulator version installable without Visual Studio
or some SDK? Should be able to run under W2K...

Greetings

Markus
 
Markus Humm said:
Hello,

how to scroll to the last line in a multiline textbox? ScrollTo
doesn't work as

- even if the textbox got it's focus via .focus first the cursor
was not in it
- I don't know how to programatically set the cursor to the end
of the text

Any hints?

The simplest way is something like this:

textBox.SelectionLength = 0;
textBox.SelectionStart = textBox.Text.Length;
textBox.ScrollToCaret();

If you are looking to append text to a multiline textbox then scroll
to the end, so you can always see the last few lines of text, I found
this article very helpful:

http://blog.opennetcf.com/afeinman/PermaLink,guid,7e8df78c-a583-4b35-ae5d-02207210ab40.aspx

Hope this helps,

----Scott.
 
Back
Top