WebBrowser中html元素如何触发winform事件 z
2021-02-03 21:16
标签:end str his orm message 如何 code rms handle 只要注册一下事件就可以了。 C#代码如下: WebBrowser中html元素如何触发winform事件 z 标签:end str his orm message 如何 code rms handle 原文地址:https://www.cnblogs.com/zeroone/p/11494522.htmlusing System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication5
...{
public partial class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
...{
this.webBrowser1.Navigate("");
this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
...{
if (e.Url.ToString() != this.webBrowser1.Url.ToString()) return;
foreach(System.Windows.Forms.HtmlElement el in this.webBrowser1.Document.GetElementsByTagName("input"))
...{
if (el.Name == "btnG")
...{
el.Click += new HtmlElementEventHandler(Form1_Click);
}
}
}
void Form1_Click(object sender, HtmlElementEventArgs e)
...{
MessageBox.Show("jinjazz pass");
}
}
}
文章标题:WebBrowser中html元素如何触发winform事件 z
文章链接:http://soscw.com/index.php/essay/50597.html