I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?
Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was
webCtrl.Document.Window.ScrollTo(0, int.MaxValue);
This is probably overkill, but you could also invoke script on the WebBrowser control and then use the scroll properties of the body tag. Or the scrollTo method of the window.
To invoke script, the WebBrowser control has a Document property that represents the document object from the DOM. It has a method called InvokeScript that you can pass a string of JavaScript to be executed.
But... if the AutoScrollOffset property works... yeah, I'd just use that instead of getting into JavaScript :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With