我可以使用 mshtml 完成我需要做的大部分事情,但我对如何将复选框输入元素设置为“已选中”感到有点困惑。情况是这样的...
IHTMLElementCollection inputElements = (IHTMLElementCollection)doc.all.tags("input");
foreach (IHTMLElement el in inputElements)
{
string elementHtml = el.outerHTML;
string termsOfServiceIdentifier = "id=chkUTOS_ver2";
// select the Terms of Service checkbox
if (elementHtml.Contains(termsOfServiceIdentifier))
{
HTMLInputElement chkTOS = (HTMLInputElement)el;
chkTOS.@checked = true; // that's the solution. Thanks Wayne.
}
else
{
// do nothing - we're not interested in this element
}
}
预先感谢您的帮助!
格雷格
最佳答案
HTMLInputElement将 Checked 属性公开为 bool 值
关于c# - 如何使用 mshtml 将复选框设置为 "checked"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/814220/