private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (isUIClick1) SetComboItem("DD1", comboBox1.Text); isUIClick1 = false; } public void SetComboItem(string id, string value) { HtmlElement ddl = webBrowser1.Document.GetElementById(id); foreach (HtmlElement item in ddl.Children) { if (item.InnerText == value) { value = item.GetAttribute("Value"); break; } } foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("select")) { if (el.Id == "DDl2") FillComboBox(el, comboBox2); else if (el.Id == "DD3") FillComboBox(el, comboBox3); } private void FillComboBox(HtmlElement el, System.Windows.Forms.ComboBox cbx) { bool selected = false; string selectedText = ""; foreach (HtmlElement comboItem in el.Children) cbx.Items.Add(comboItem.InnerText); foreach (HtmlElement comboItem in el.Children) { selected = Convert.ToBoolean(comboItem.GetAttribute("Selected")); if (selected) { selectedText = comboItem.InnerText; break; } } cbx.Text = selectedText; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)