首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-01-02 
webbrowser控件中选定radio项的问题页面上有三个radio,如下:INPUTtype radio idDeliveryIDvalue1029

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;
}
}

热点排行