[英]How to call the Click event on a page in the Windows Forms WebBrowser control?
如何在WebBrowser控件中的按钮上调用Click事件?
Use the HtmlElement.InvokeMember() method. 使用HtmlElement.InvokeMember()方法。 Here's an example that clicks the Google home page "I feel lucky" button:
这是单击Google主页“我感到很幸运”按钮的示例:
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
if (webBrowser1.Url.Host.EndsWith("google.com")) {
HtmlDocument doc = webBrowser1.Document;
HtmlElement ask = doc.All["q"];
HtmlElement lucky = doc.All["btnI"];
ask.InnerText = "stackoverflow";
lucky.InvokeMember("click");
}
}
The click event gets invoked in response to a user clicking on the control. 响应用户单击控件而调用click事件。 You (normally) wouldn't 'call' the event directly yourself.
您(通常)不会自己直接“调用”该事件。
Can you clarify your question? 你能澄清你的问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.