[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

How to scroll a WebBrowser control?

Martin Christiansen

10/30/2008 10:33:00 PM

Hi all.

I have a form with a WebBrowser control on it, and I easily get it to
display a certain web page by setting its Url property.

However, the interesting part of the page is out of view, because it is
located much further down the page (below the visible part displayed). So I
need to programatically search for a specific word (or phrase) on the page
and scroll that word (or phrase) into view (if found).

How can that be done?

I'm using VS2008 and C#.

-Martin.


2 Answers

Jani J?rvinen [MVP]

11/1/2008 2:56:00 PM

0

Hi Martin,

> However, the interesting part of the page is out of view, because it is
> located much further down the page (below the visible part displayed).

I don't have a definite answer for your scrolling question, but I can give
you pointers to the right direction.

The first one is to send a Windows scrolling message to the browser window.
You can get the window handle by reading the Handle property of the web
browser control.

Of course, the problem with this approach is that just scrolls the amount
you specify, but doesn't guarantee the text you are looking for will be
found. My sending a proper message, you could probably activate the Find
command, and then simulate keystrokes, and then let the browser find the
text.

But, all this is a mediocore solution at best. This leads to the question:
are you in control of the web page shown? If yes, why not develop a page
which would have for example named HTML anchors (A) that you could directly
link into, all get rid of the searching altogether?

Hope this gives you ideas where to look!

Thanks!

--
Regards,

Mr. Jani Järvinen
C# MVP
Vantaa, Finland
janij@removethis.dystopia.fi
http://www.saunalahti...


Martin Christiansen

11/1/2008 4:02:00 PM

0


"Jani Järvinen [MVP]" <janij@removethis.dystopia.fi> skrev i en meddelelse
news:uoF33HDPJHA.4776@TK2MSFTNGP05.phx.gbl...
> Hi Martin,
>
>
> I don't have a definite answer for your scrolling question, but I can give
> you pointers to the right direction.
>
Hi Jani and thank you for your participation in my problem. No, I'm not in
control of the web site, so I cannot place an anchor on the page, but I've
also thought of simulating the "find" command by faking keyboard input. But
I don't know how to do it.

Anyway, thank you for your ideas.

Greetings, Martin.