winform textbox 文本传值网页文本框的方法
how to winform texboxt Text transfer value web page textbox
我有textbox1
,我想把textbox1.Text
转成webbrowser1
网页文本框,怎么办?
我有以下代码,但网页文本框选择的索引更改事件未触发。如何做到这一点?
private void button2_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
//HTMLControl.Style = "'display: none;'";
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
}
}
请看下图
您正在尝试向网页输入文本然后让浏览器引发输入框的 change/input 事件?您必须调用 "onChange" 事件或其他事件。
下面我让 WebBrowser 引发 keydown 事件,使用 SendKey:
private void button2_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
//HTMLControl.Style = "'display: none;'";
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
HTMLControl2.Focus(); // Set focus to input box
SendKeys.SendWait("{Right}"); // Send "Right" key
textBox1.Focus(); // Give focus back for one of WinForms control
}
}
我有textbox1
,我想把textbox1.Text
转成webbrowser1
网页文本框,怎么办?
我有以下代码,但网页文本框选择的索引更改事件未触发。如何做到这一点?
private void button2_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
//HTMLControl.Style = "'display: none;'";
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
}
}
请看下图
您正在尝试向网页输入文本然后让浏览器引发输入框的 change/input 事件?您必须调用 "onChange" 事件或其他事件。
下面我让 WebBrowser 引发 keydown 事件,使用 SendKey:
private void button2_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
//HTMLControl.Style = "'display: none;'";
if (HTMLControl2 != null)
{
// HTMLControl2.Style = "display: none";
HTMLControl2.InnerText = textBox1.Text;
HTMLControl2.Focus(); // Set focus to input box
SendKeys.SendWait("{Right}"); // Send "Right" key
textBox1.Focus(); // Give focus back for one of WinForms control
}
}