【问题标题】:how to send Press Enter Key to htmlelement in web browser control如何在 Web 浏览器控件中将 Press Enter 键发送到 htmlelement
【发布时间】:2013-12-01 03:37:21
【问题描述】:

我正在开发包含 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,但它们都不起作用..

如何做到这一点?

【问题讨论】:

标签: c# webbrowser-control


【解决方案1】:

来自MSDN - Navigated

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-09
    • 2010-11-22
    • 1970-01-01
    • 2020-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多