2016-03-02 73 views
1

我有textbox1,我想将textbox1.Text转换成webbrowser1网页文本框,怎么做到这一点?如何winform texboxt文本传输值网页文本框

我有下面的代码,但网页文本框中选中的索引更改事件未被触发。这个怎么做?

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; 
    } 
} 

请参见下面的图像

enter image description here

+0

私人无效button2_Click(对象发件人,EventArgs的) { 的HTMLDocument DOC = webBrowser1.Document; HtmlElement HTMLControl2 = doc.GetElementById(“flightno-filter”); //HTMLControl.Style =“'display:none;'”; (HTMLControl2!= null) {HTMLControl2.Style =“display:none”; HTMLControl2.InnerText = textBox1.Text; } }但web浏览器选择的indexchange事件没有被解雇 –

+1

通过编辑添加代码,你可以看到它在评论部分中是不可读的。 –

+0

哪些事件未被解雇?添加该代码请 – SamGhatak

回答

1

你试图输入文本的网页,然后使使web浏览器提高输入框的变化/输入事件?您必须调用“onChange”事件或其他事件。

娄我使web浏览器提高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 

    } 
} 
+0

感谢您的回复:)其作品为我..感谢您的伟大, –

+0

以及如何触发onclick事件? –

+0

这是另外一个问题,因为你在上面的问题中没有提出这个问题。创建新的问题并描述您正在工作的网站(URL),您尝试点击哪个元素,您尝试过的内容(描述需要详细信息,否则人们将停靠您)。 – Sakura