How to get textbox (rich or plain) to remain scrolled to the bottom?
-
Hi, I use textboxes to log application messages sometimes, and want them to stay scrolled to the bottom (most recent message). How can this be achieved? I've tried both textbox.text += "my message", and textbox.appendtext("my message") - they don't perform the behavior I'm after. Thanks for any ideas, cdj
-
Hi, I use textboxes to log application messages sometimes, and want them to stay scrolled to the bottom (most recent message). How can this be achieved? I've tried both textbox.text += "my message", and textbox.appendtext("my message") - they don't perform the behavior I'm after. Thanks for any ideas, cdj
-
Hi, I use textboxes to log application messages sometimes, and want them to stay scrolled to the bottom (most recent message). How can this be achieved? I've tried both textbox.text += "my message", and textbox.appendtext("my message") - they don't perform the behavior I'm after. Thanks for any ideas, cdj
Try calling
ScrollToCaret
after appending the new text.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hi, I use textboxes to log application messages sometimes, and want them to stay scrolled to the bottom (most recent message). How can this be achieved? I've tried both textbox.text += "my message", and textbox.appendtext("my message") - they don't perform the behavior I'm after. Thanks for any ideas, cdj
Stefan is right. ScrollToCaret is what you're looking for. The only pitfall to using it, though, is that the TextBox has to have the input focus in order for it to work. Call the
Focus
method on the TextBox before you callScrollToCaret
.Dave Kreskowiak Microsoft MVP - Visual Basic
-
try using this: textbox.text= "my message" + textbox.text hopes it helps, Wachill Signature has been encrypted
It would, were I willing to accept reverse chronological order. Thanks though!
-
Stefan is right. ScrollToCaret is what you're looking for. The only pitfall to using it, though, is that the TextBox has to have the input focus in order for it to work. Call the
Focus
method on the TextBox before you callScrollToCaret
.Dave Kreskowiak Microsoft MVP - Visual Basic
Ah! I've tried scrolltocaret before, and noticed that it did absolutely nothing. It must be the focus-thing that bit me. I'll try scrolltocaret in combination with giving the textbox the focus. Hm. It occurs to me: if the textbox MUST have focus in order for scrolltocaret to be effective, doesn't that mean it would be difficult to specialize the textbox class into a textbox + AutoScrollToBottom property class - no? Thanks a bunch everyone!
-
Ah! I've tried scrolltocaret before, and noticed that it did absolutely nothing. It must be the focus-thing that bit me. I'll try scrolltocaret in combination with giving the textbox the focus. Hm. It occurs to me: if the textbox MUST have focus in order for scrolltocaret to be effective, doesn't that mean it would be difficult to specialize the textbox class into a textbox + AutoScrollToBottom property class - no? Thanks a bunch everyone!
It's possible to make a Textbox that autoscrolls, but you'd have to send the textbox window handle the appropriate window messages to get it to scroll. The reason why the ScrollToCaret function needs the TextBox to have the focus is because it depends on the existance of the caret. The caret doesn't exist in the TextBox until the TextBox has the focus.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
It's possible to make a Textbox that autoscrolls, but you'd have to send the textbox window handle the appropriate window messages to get it to scroll. The reason why the ScrollToCaret function needs the TextBox to have the focus is because it depends on the existance of the caret. The caret doesn't exist in the TextBox until the TextBox has the focus.
Dave Kreskowiak Microsoft MVP - Visual Basic
Hm - Looking into the prospects for an autoscroll textbox property, and I came across the dotnet scrollablecontrol class, which apparently textbox doesn't n-inherit from. http://msdn2.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.aspx Cute little learning project: determine exactly what's involved with deriving from textbox to include an autoscroll property. Thanks!
-
Hm - Looking into the prospects for an autoscroll textbox property, and I came across the dotnet scrollablecontrol class, which apparently textbox doesn't n-inherit from. http://msdn2.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.aspx Cute little learning project: determine exactly what's involved with deriving from textbox to include an autoscroll property. Thanks!
ScrollableControl doesn't do what you think it does. It doesn't automatically scroll to the bottom or anything like that. It supplies scrollbars that automatically appear if the content of the child controls exceeds its boundries. There are currenly two controls and two components that are direct inheritors of this class: Panel and ToolStrip, and ContainerControl, and Design.ComponentTray.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
ScrollableControl doesn't do what you think it does. It doesn't automatically scroll to the bottom or anything like that. It supplies scrollbars that automatically appear if the content of the child controls exceeds its boundries. There are currenly two controls and two components that are direct inheritors of this class: Panel and ToolStrip, and ContainerControl, and Design.ComponentTray.
Dave Kreskowiak Microsoft MVP - Visual Basic
Oh. Boy is the name "autoscroll" misleading for a property then. Thanks!