Webbrowser Control in VB.NET Windows Application

C Williams
C Williams used Ask the Experts™
I have a windows application where a webbrowser is embedded in a tabbed control...when the application starts the webbrowser shows a default graph from the web which is sized perfectly within the frame.  But if I update the webbrowser with a new graph, the size of the webpage is larger than the frame...presenting the user with scroll bars.  

How do I get the web page to fit in the window, as it was when the application started?

Below are some of the options that I've tried.

Any help would be much appreciated.

Public Sub graphUpdate()
        Dim myTicker = txtTicker.Text
        Dim myAddressDaily = ConfigurationManager.AppSettings("graph1Day") & myTicker
        Dim myAddressWeekly = ConfigurationManager.AppSettings("graph1Week") & myTicker
        Dim myAddressYearly = ConfigurationManager.AppSettings("graph1Year") & myTicker

        txtTicker.Text = UCase(txtTicker.Text)

        txtHistory.Text = myTicker
        'Me.browserDaily.Dock = DockStyle.None
        'Me.browserDaily.Dock = DockStyle.Fill
        'Me.browserDaily.SetBounds(0, 0, 417, 220)
        'Me.browserDaily.MaximumSize() = "417"
        'Me.browserDaily.Top = 0
        'Me.browserDaily.Height = 200
        'Me.browserDaily.Width = 417
        'Me.browserDaily.Document.Body.ScrollLeft = 0

        formParent.ToolStripStatusLabel.Text = "Graphs refreshed...Ready"
    End Sub
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

If you do not want the scroll bars, you can just hide them by setting the property
ScrollBarsEnabled = False


Having the scroll bars enabled wouldn't help.  The size of the graph still gets enlarged, so using this option would show a truncated image with no ability to scroll to see the rest of the image.

My main purpose is to have the image/webpage not get enlarged beyond it's parent container where it has to use scrollbars.

Have you tried docking the controller in the designer and not in code?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.


Yes, I have, that was my original attempt prior to trying to dock it in the code.

Are you certain it's the WebBrowser control that is extended beyond the container? Try disabling the AutoScroll of the container and docking the WebBrowser within the container?


The container was originally a single tab of a tab control, which already had the autoscroll set to false.  After your suggestion, I placed a panel on the tab control, set that to fill, then placed the webbrowser back (now set on the panel), which also is set to autoscroll to false...same result.  When updated the webbrowser extended beyond the viewable area.

Are you able to supply a small sample application? I'll try and reproduce the issue here, but your example will give me the webpage the right size and then after a refresh, the scroll bars appearing.

I am failing to reproduce the issue you are having :o( From what I understand.
Was not able to resolve, and now I'm getting emails stating that the question is old...so I have to close the question.  Thanks for at least attempting to help me resolve this PhilAl

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial