Results 1 to 2 of 2

Thread: select drop down item?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    select drop down item?

    webbrowser control in .NET 2.0 - how would I select an item from the drop down list? I know there is a Children html element collection in the HtmlElement collection....and I know I can retrieve the contents/values of the items from the drop down list but how do I actually "set" or select the item from the list?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Lively Member
    Join Date
    Jun 2003
    Posts
    89

    Re: select drop down item?

    you just have to set the value of the dropdownlist, if I remember correctly.

    This this:

    WebBrowser1.Document.GetElementById("dropdownlistID").SetAttribute("value", "12");


    if the dropdownlist doesn't have an id attribute, you should enumerate all the html controls having the SELECT tagname.

    HtmlElementCollection collection = WebBrowser1.Document.GetElementsByTagName("select");

    foreach(HtmlElement ddl in collection){
    ddl.SetAttribute("value", "12");
    }
    - mo! I said MOOOOOOO!!
    - ...yep, that's a cow, alright.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width