Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey, I'm trying to get my web browser to scroll by button using this code:

VB
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    WebBrowser1.ScrollBarsEnabled = False
End Sub

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
    WebBrowser1.Document.Body.ScrollTop = WebBrowser1.Document.Body.ScrollTop - 10

End Sub

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
    WebBrowser1.Document.Body.ScrollTop = WebBrowser1.Document.Body.ScrollTop + 10

End Sub


I was wondering if someone could help me set it up so that when I click and hold down the button, it will continuously scroll down until you release the click, like a normal scroll bar.
Posted
Comments
Sergey Alexandrovich Kryukov 2-Oct-13 0:54am    
Does a single button press scroll? If so, auto-repeat will do continues scrolling...
—SA
Tyler Wellman 2-Oct-13 8:11am    
yes when I click it, the page scrolls, any way you could give me an example of a repeat button using
WebBrowser1.Document.Body.ScrollTop = WebBrowser1.Document.Body.ScrollTop - 10

please?
Sergey Alexandrovich Kryukov 2-Oct-13 11:45am    
I did not ask about a click, it's obvious. How about an error key press?
—SA
Tyler Wellman 2-Oct-13 12:03pm    
Never mind I just changed 10 to 50 and it scrolls easily enough per click, would rather it continuously scroll when you click and hold the button for ease of use, but it works, thanks anyway.
Sergey Alexandrovich Kryukov 2-Oct-13 12:13pm    
:-)

In C# you could add a timer and do something like this
C#
int position = 0;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
    timer1.Start();
}

private void button1_MouseUp(object sender, MouseEventArgs e)
{
    timer1.Stop();
}

private void timer1_Tick(object sender, EventArgs e)
{
    position++;
}

Then every tick of the timer will set the position.
You will have to change the code to something you could use,
but you get the big picture here.
 
Share this answer
 
Changed 10 to 50, not a solution but it's easier to scroll.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900