<p>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?</p>

[{'answer_id': 46463, 'author': 'Oded', 'author_id': 1583, 'author_profile': 'https://Stackoverflow.com/users/1583', 'pm_score': 2, 'selected': False, 'text': '<p>I would use the AutoScrollOffset property and set it the the bottom left of the WebBrowser control, so something like:</p>\n\n<pre><code>webCtrl.AutoScrollOffset = new Point(0, webCtrl.Height);\n</code></pre>\n'}, {'answer_id': 46903, 'author': 'David Mohundro', 'author_id': 4570, 'author_profile': 'https://Stackoverflow.com/users/4570', 'pm_score': 2, 'selected': False, 'text': "<p>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.</p>\n\n<p>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.</p>\n\n<p>But... if the AutoScrollOffset property works... yeah, I'd just use that instead of getting into JavaScript :)</p>\n"}, {'answer_id': 50264, 'author': 'Ryan Lanciaux', 'author_id': 1385358, 'author_profile': 'https://Stackoverflow.com/users/1385358', 'pm_score': 4, 'selected': True, 'text': '<p>Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was </p>\n\n<pre><code>webCtrl.Document.Window.ScrollTo(0, int.MaxValue);\n</code></pre>\n'}, {'answer_id': 22340865, 'author': 'IlPADlI', 'author_id': 2430943, 'author_profile': 'https://Stackoverflow.com/users/2430943', 'pm_score': 0, 'selected': False, 'text': "<p>You can keep scroll position on top, and insert new message on top.</p>\n\n<p>that don't need scroll to bottom, its look like twitter :)</p>\n\n<pre><code>user2:\n  new message   ← a new message is insert on top\n\nuser1:\n  old message\n</code></pre>\n"}, {'answer_id': 40783280, 'author': 'Chathuranga Abeyrathne', 'author_id': 7204504, 'author_profile': 'https://Stackoverflow.com/users/7204504', 'pm_score': 0, 'selected': False, 'text': '<pre><code> public virtual void ScrollMessageIntoView()\n        {\n\n            System.Windows.Forms.Application.DoEvents();\n            if (browser == null || browser.IsDisposed)\n                return;\n\n            if (browser.Document == null)\n            {\n                browser.Document.Window.ScrollTo(0,\n                browser.Document.Body.ScrollRectangle.Height);\n            }\n        }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/46454', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1385358/']