I am porting a VB 6.0 application to C# that automates navigation of
multiple web pages within a site and extracts information from some of
the pages. One of the pages contains a listbox containing a number of
countries. The default value that is set is not the value I need to
use.
The HTML in the web page looks like this:
<select name="country" style="" onchange="" multiple id="countryList"
size="7">
<option value="*" selected> All Countries and Territories </option>
<option value="------0">------</option>
<option value="AU"> Australia </option>
<option value="AT"> Austria </option>
<option value="BE"> Belgium </option>
<option value="BR"> Brazil </option>
<option value="CA"> Canada </option>
<option value="CN"> China </option>
<option value="DK"> Denmark </option>
<option value="FI"> Finland </option>
<option value="FR"> France </option>
<option value="DE"> Germany </option>
<option value="HK"> Hong Kong </option>
<option value="IT"> Italy </option>
<option value="JP"> Japan </option>
<option value="NL"> Netherlands </option>
<option value="NO"> Norway </option>
<option value="PT"> Portugal </option>
<option value="SG"> Singapore </option>
<option value="KR"> South Korea </option>
<option value="ES"> Spain </option>
<option value="SE"> Sweden </option>
<option value="CH"> Switzerland </option>
<option value="TW"> Taiwan </option>
<option value="GB"> United Kingdom </option>
<option value="US"> United States </option>
</select>
In VB6 the selected value is changed this way:
' De-select the first (default) value in the list
wb1.All("country").Options(0).Selected = False
' Select the 26th item (zero-based index) in the list
wb1.All("country").selectedIndex = 25
wb1 is an HTMLDocument object.
I cannot figure out how to access the Options collection or the
selectedIndex property with the .NET 2.0 Webbrowser object. Any ideas
how I can do this in C#?