WebBrowser Control Scrollbar Positions


  • Hi , Please halp me ???
    Many controls allow a scroll bar to be visable. Is there a way to find the max, min, and current values of these scrollbars. And can you set the position (value) with .net code?
    is it possable to get the position of a browser controls scoll bar position?
    then then, set its position?
    Please Write Sample Code ...
    Tuesday, October 02, 2007 2:50 AM


All replies


    Hi, SahandS.One,


    Based on my understanding, you want to know the Maximum, Minimum and Value of the ScrollBars which belong to your controls, don't you?


    To get those values, you should divide the controls into two groups.

    One group is for the controls which inherit from ScrollableControl class, such as Panel and Form,

    and then you can get the values through HorizontalScroll and VerticalScroll property.

    For example

    Code Block






    And you can set the position by setting the Value property.


    The other group is for the controls which wrap the Win32 Com controls, such as WebBrowser.

    And the WebBrowser is a very different Com control, it is not easy to get the position of its scroll bars.

    However, you can get its Maximum value by getting its Window size

    Code Block


    And you can set its position by ScrollTo method

    Code Block

    webBrowser1.Document.Window.ScrollTo(0, 200);


    More info


    Hope this helps,


    Thursday, October 04, 2007 6:04 AM
  • > "it is not easy to get the position of its scroll bars."


    Looks simple to me:


    Code Snippet

            Dim webbrowser1scrollleft As Integer = WebBrowser1.Document.Body.ScrollLeft
            Dim webbrowser1scrolltop As Integer = WebBrowser1.Document.Body.ScrollTop
            WebBrowser1.Document.Body.ScrollLeft = webbrowser1scrollleft
            WebBrowser1.Document.Body.ScrollTop = webbrowser1scrolltop


    Tuesday, February 19, 2008 2:01 PM
  • using the webbrowser control in .NET 2 do the following - works real well and will automatically scroll to the bottom as the page gets bigger and bigger. I am using the control in a IM Chat application and as new chats come in I want to make sure I scroll to the bottom - try this it works for me:



    Class Form1


    Private dt As String = ""



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    If dt <> "" Then

    dt = dt &



    End If

    dt = dt &



    Me.WebBrowser1.DocumentText = dt

    Application.DoEvents() 'most important as it gives a chance for the page to refresh




    If Not Me.WebBrowser1.Document Is Nothing Then


    Me.WebBrowser1.Document.Window.ScrollTo(0, Me.WebBrowser1.Document.Body.ScrollRectangle.Height)


    End If


    Catch ex As Exception


    "BAD " & ex.Message.ToString())


    End Try


    End Sub

    Wednesday, January 06, 2010 2:39 AM
  • Thank you very much Realanswers it helped me a lot
    Monday, March 22, 2010 9:23 AM