在C#中使用WebBrowser控件,需要先把WebBrowser控件和MSHTML组件添加进来.
使用的代码如下:
mshtml.IHTMLDocument2 document = (mshtml.IHTMLDocument2)axWebBrowser1.Document;
mshtml.IHTMLInputTextElement text1= (mshtml.IHTMLInputTextElement)document.all.item("text1", null);
text1.value = "你的名字"
mshtml.IHTMLSelectElement select1= (mshtml.IHTMLSelectElement)document.all.item("select1", null);
select1.selectedIndex = 1;
mshtml.IHTMLTextAreaElement content = (mshtml.IHTMLTextAreaElement)document.all.item("content", null);
content.value = "这是休息";
//mshtml.IHTMLFormElement Form1 = (mshtml.IHTMLFormElement)document.all.item("Form1", null);
//Form1.submit();
mshtml.HTMLButtonElement Button1 = (mshtml.HTMLButtonElement)document.all.item("Button1", null);
Button1.onclick = "true";
Button1.click();
发表时间: 2005-05-23 15:34
[ 此贴被XChinux在2005-08-13 09:09重新编辑 ]