如何从winform文本框触发网页文本框onclick事件 [英] how to webpage textbox onclick event fire from winform textbox
本文介绍了如何从winform文本框触发网页文本框onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,当我从我的 winform 文本框搜索并单击搜索按钮但网页文本框 onclick 事件未触发时.这该怎么做?这是:
解决方案
代码如下:
Form1.cs:
private void textBox1_TextChanged(object sender, EventArgs e){HtmlDocument doc = webBrowser1.Document;HtmlElement HTMLControl2 = doc.GetElementById("searchInput");if (HTMLControl2 != null){//HTMLControl2.Style = "display: none";HTMLControl2.InnerText = textBox1.Text;HTMLControl2.Focus();SendKeys.SendWait("{ENTER}");textBox1.Focus();}}
其他都是默认的.
I have below code,when i search from my winform textbox and click search button but webpage text box onclick event not fired. How to do this? here is :http://www.heathrow.com/arrivals when i click search button page still same position, show in 2nd number image. internet explorer 11 i have installed
private void button2_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("searchInput");
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
HTMLControl2.Focus();
SendKeys.SendWait("{ENTER}");
textBox1.Focus();
}
}
解决方案
Here is the code:
Form1.cs:
private void textBox1_TextChanged(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("searchInput");
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
HTMLControl2.Focus();
SendKeys.SendWait("{ENTER}");
textBox1.Focus();
}
}
Anything else is default.
这篇关于如何从winform文本框触发网页文本框onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文