Skip to content

Instantly share code, notes, and snippets.

@dck-jp
Created June 6, 2015 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dck-jp/a30b1dd19820ee7ba903 to your computer and use it in GitHub Desktop.
Save dck-jp/a30b1dd19820ee7ba903 to your computer and use it in GitHub Desktop.
SHDocVwSample09
public void CheckCheckBox()
{
var IE = new SHDocVw.InternetExplorer();
IE.Visible = true;
object URL = "http://law.e-gov.go.jp/";
IE.Navigate2(ref URL);
IE.Wait();
var doc = IE.Document as mshtml.IHTMLDocument3;
//1つ目の方法
foreach (mshtml.HTMLInputElement ele in doc.getElementsByName("H_YOMI_GUN")) //item(index: ) では指定できず…(謎
{
if (ele.value == "3") { ele.click(); } //valueの値を見て選択
}
//2つ目の方法
foreach (mshtml.HTMLInputElement ele in doc.getElementsByName("H_RYAKU"))
{
if (ele.value == "2") { ele.setAttribute("checked","checked"); } //valueの値を見て選択 (方法その2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment