Home All Groups Group Topic Archive Search About

Automaticaly Clicking a Checkbox on a webbrowser control

Author
16 Aug 2006 6:44 AM
ColliersWNC
I know there is probably a simple solution to this, but I haven't
figured it out yet or seen it else where.

Imagine you had a simple web page that looked like the following:

<html>
<input name="dgSelect:_ctl0:cbSelect" id="dgSelect__ctl0_cbSelect"
type="checkbox" />
</html>

After loading this web page in to a WebBrowser Control on a VB form,
how would you have VB check the box?  I know this seems simple and it's
probably so easy that nobody has bothered to ask it before, but I can't
figure it out and haven't seen a solution for it yet so I thought I'd
ask.

kb

Author
16 Aug 2006 5:44 PM
tomb
This is not VB, it is simple HTML.  Include  CHECKED in the attribute list.

T

Colliers***@gmail.com wrote:

Show quoteHide quote
>I know there is probably a simple solution to this, but I haven't
>figured it out yet or seen it else where.
>
>Imagine you had a simple web page that looked like the following:
>
><html>
><input name="dgSelect:_ctl0:cbSelect" id="dgSelect__ctl0_cbSelect"
>type="checkbox" />
></html>
>
>After loading this web page in to a WebBrowser Control on a VB form,
>how would you have VB check the box?  I know this seems simple and it's
>probably so easy that nobody has bothered to ask it before, but I can't
>figure it out and haven't seen a solution for it yet so I thought I'd
>ask.
>
>kb
>

>
Author
17 Aug 2006 1:02 AM
Gimble
Sorry I don't think I was being clear enough,  I don't have control
over the creation of the page, it's a 3rd party page.  I figured out
what I was trying to do though.  I was trying to make a function that
will check every checkbox on a page that is loaded into a webbrowser1
control.  There was no preexisting attribute "Checked" on the
checkboxes so I didn't think that I could set it directly, but the code
below works.

hopefully this will help someone out.


private sub Check_all_checkboxes()

        Dim doc As HtmlDocument
        Dim elem As HtmlElement

        doc = WebBrowser1.Document
        For Each elem In doc.All
            If elem.GetAttribute("type") = "checkbox" Then
                elem.SetAttribute("CHECKED", "CHECKED")
            End If
        Next
    End Sub




tomb wrote:
Show quoteHide quote
> This is not VB, it is simple HTML.  Include  CHECKED in the attribute list.
>
> T
>
> Colliers***@gmail.com wrote:
>
> >I know there is probably a simple solution to this, but I haven't
> >figured it out yet or seen it else where.
> >
> >Imagine you had a simple web page that looked like the following:
> >
> ><html>
> ><input name="dgSelect:_ctl0:cbSelect" id="dgSelect__ctl0_cbSelect"
> >type="checkbox" />
> ></html>
> >
> >After loading this web page in to a WebBrowser Control on a VB form,
> >how would you have VB check the box?  I know this seems simple and it's
> >probably so easy that nobody has bothered to ask it before, but I can't
> >figure it out and haven't seen a solution for it yet so I thought I'd
> >ask.
> >
> >kb
> >
> > 
> >