关于AxWebBrowser控件中取得下拉框并操作的问题

qugui 2007-02-07 12:01:55
本人想在自己写的浏览器中取得如下的下拉框,并在程序里对其操作。但不知道如何下手,请高人指点。

<select name="verb" id="verb" style="height:19px;width:104px;">
<option value="movieName">影片名称</option>
<option value="movieDao">影片导演</option>
<option value="movieLang">影片语言</option>
<option value="movieYan">影片演员</option>

</select>
...全文
298 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcl8260 2007-03-08
  • 打赏
  • 举报
回复
帮顶
丛林蚂蚁 2007-03-08
  • 打赏
  • 举报
回复
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.axWeb_Browser.Document;
mshtml.HTMLSelectElement frmselect = (mshtml.HTMLSelectElement)doc.all.item("verb", 0);
//修改选中的项.
frmselect.selectedIndex = 0;

蒋晟 2007-02-08
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/TopicView3.asp?id=5166830
http://community.csdn.net/Expert/TopicView2.asp?id=5186832
winner2050 2007-02-07
  • 打赏
  • 举报
回复
右键转化为服务器控件就得了。
jxf654 2007-02-07
  • 打赏
  • 举报
回复
up
qqchen79 2007-02-07
  • 打赏
  • 举报
回复
1. Add Reference: COM -> Microsoft HTML Object Library (mshtml)。

2. mshtml.IHTMLSelectElement select = (mshtml.IHTMLSelectElement)
webBrowser1.Document.GetElementById("verb").DomElement;

3. To set the selected option:
select.selectedIndex = 3;

4. To retrieve options under the select element:
for(int i = 0; i < select.length; ++ i)
{
mshtml.IHTMLOptionElement opt = select.item(i, i) as mshtml.IHTMLOptionElement;
//do something with it
}

5. To get the current selected option:
mshtml.IHTMLOptionElement curr = select.item(select.selectedIndex, select.selectedIndex) as mshtml.IHTMLOptionElement;

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧