title: c# Select Single Item in Multiple Drop Down List in WebBrowser Control
body: <p>I've been searching for a solution for this problem, but have yet to find one that works.  I have a webBrowser control.  There is a multiple drop down list that is structured like this:</p>
  
  <pre><code>&lt;select name="cars" multiple&gt;
    &lt;option value="volvo"&gt;Volvo&lt;/option&gt;
    &lt;option value="saab" SELECTED&gt;Saab&lt;/option&gt;
    &lt;option value="opel"&gt;Opel&lt;/option&gt;
    &lt;option value="audi" SELECTED&gt;Audi&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;p&gt;Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.&lt;/p&gt;
  </code></pre>
  
  <p>There are already some options selected.  I need to select one other option, such as "Volvo"
  The typical was to do this would be to hold the ctrl key and right click on the option.  I was looking at the sendKeys class, but I'm not entirely sure I'm doing it right.
  Here is what I have tried:</p>
  
  <pre><code>foreach (HtmlElement item in webBrowser1.Document.GetElementsByTagName("option"))
  {
      if (item.InnerText == "Volvo")
      {
          item.Focus();
          SendKeys.Send("^(+)");//sends ctrl-space
      }
  }
  </code></pre>
  
  <p>It doesn't seem to give the item focus, so I'm not sure if the SendKeys is working or not.  </p>
  
  <p>I also tried this :</p>
  
  <pre><code>foreach (HtmlElement item in webBrowser1.Document.GetElementsByTagName("option"))
  {
      if (item.InnerText == "Volvo")
      {
          item.SetAttribute("SELECTED", "");
      }
  }
  </code></pre>
  
  <p>...but this does not seem to work either.<br>
  Any help is appreciated</p>