[英]how to send Press Enter Key to htmlelement in web browser control
我正在開發包含 Web 瀏覽器控件的 win 表單應用程序,在網頁中有一個文本框字段,我將其作為 htmlelement 獲取。
我用字符串值正確填充它,然后我想發送回車鍵以提交其中的值..
這是我到目前為止的代碼:
HtmlDocument hd = wbr.Document;//wbr is web browser control
HtmlElement he = hd.GetElementById("response_field");
he.SetAttribute("value", ans);//filled correctly
wbr.Select();
he.Focus();
he.InvokeMember("submit");
SendKeys.Send("{ENTER}");
我嘗試了調用成員,嘗試了 sendkey,但它們都不起作用..
這個怎么做?
來自MSDN - 導航:
// Navigates to the URL in the address box when
// the ENTER key is pressed while the ToolStripTextBox has focus.
private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Navigate(toolStripTextBox1.Text);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.