TextBox question

  • Thread starter Thread starter Brad Markisohn
  • Start date Start date
B

Brad Markisohn

In a multi-line text box, how can make sure that the most current line is
always displayed? Currently, I have to manually move the scroll bar to the
end of the box. Is there a way to automate this?

TIA

Brad
 
Hi Brad,

Place this in the textbox's enter event:
SendKeys.Send("^{END}") // control end

HTH,

Bernie Yaeger
 
Bernie,

This doesn't seem to work. The behavior is the same with and/or without.
I've tried some of the obvious stuff like setting the SelectionStart
property = text.length without success. The textbox is populated by an
event containing a single text message. The event is fired repetitively
until the process stops or the textbox fills up. I'd like the user to see
the most current message as it's added and be able to see the last message
posted without having to manually scroll.

Thanks

Brad
 
* "Brad Markisohn said:
In a multi-line text box, how can make sure that the most current line is
always displayed? Currently, I have to manually move the scroll bar to the
end of the box. Is there a way to automate this?

Call the control's 'Focus' method, then its 'Select' method, set the
selection after the last character and call its 'ScrollToCaret' method.
 
Herfried,

That worked! Interestingly, this works the same with or without a call to
the control's focus method. Is this call necessary?

Thanks for your help.

Brad
 
* "Brad Markisohn said:
That worked! Interestingly, this works the same with or without a call to
the control's focus method. Is this call necessary?

If it works, it's not necessary (make sure it works if the control
doesn't have the focus). I remember that it only worked with a
RichTextBox control if it had the focus.
 
Back
Top