读书人

webbrowser控件中选定radio项的有关问

发布时间: 2012-01-02 22:40:04 作者: rapoo

webbrowser控件中选定radio项的问题
页面上有三个radio,如下:

<INPUT type= "radio " id=DeliveryID value=1029 NAME= "DeliveryID ">
<INPUT type= "radio " id=DeliveryID value=1028 NAME= "DeliveryID ">
<INPUT type= "radio " id=DeliveryID value=1050 NAME= "DeliveryID ">

我需要让程序选中value=1029的那个radio,代码应该怎么写

[解决办法]
//项目中添加Micrsoft.mshtml引用
using mshtml;


IHTMLDocument2 vDocument =
(IHTMLDocument2)webBrowser1.Document.DomDocument;
foreach (IHTMLElement vElement in vDocument.all)
{
if (vElement.tagName.ToLower() == "input ")
{
IHTMLInputElement vInputElement = (IHTMLInputElement)vElement;
if (vInputElement.type.ToLower() == "radio " &&
vInputElement.value.ToLower() == "1029 ")
vInputElement.@checked = true;
}
}

读书人网 >C#

热点推荐