以编程方式在网页浏览器控件中按 Tab 键 C#

发布于 2024-12-22 09:54:47 字数 343 浏览 0 评论 0原文

我想以编程方式按 Tab 键。我使用了这段代码:

private void BrowserPage_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
  webBrowser.Select();
  webBrowser.Focus();
  PreviewKeyDownEventArgs ee = new PreviewKeyDownEventArgs(Keys.Tab);
  webBrowser_PreviewKeyDown(sen, ee);
}

但在网络浏览器中,焦点没有移动到下一个控件。

I want to press tab key programmatically. I used this code:

private void BrowserPage_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
  webBrowser.Select();
  webBrowser.Focus();
  PreviewKeyDownEventArgs ee = new PreviewKeyDownEventArgs(Keys.Tab);
  webBrowser_PreviewKeyDown(sen, ee);
}

but in web browser the focus is not moving to next control..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎歌 2024-12-29 09:54:47

确保 webBrowser 控件具有焦点并尝试下一行:

SendKeys.Send("{TAB}");

更多信息 此处此处

我希望它有帮助。

Ensure webBrowser control has the focus and try the next line:

SendKeys.Send("{TAB}");

More info here and here.

I hope it helps.

司马昭之心 2024-12-29 09:54:47

那么,当按下 Tab 键时,您想将焦点集中到网络浏览器上吗?

将您的代码放入

private void ("what tab is benig pressed on")_KeyPress(object sender,    KeyPressEventArgs e)
{
    if (e.Keychars == keys.Tab)
    {
        webBrowser.Select();
        webBrowser.Focus();
    }            
}

我认为keys.Tab应该可以工作,如果不行尝试谷歌搜索tab键的数值是什么并将其代替keys.Tab

我放置的“正在按下哪个选项卡您将运行按键在那...不是网络浏览器

希望这有帮助抱歉,如果我不正确,我只花了 7 个小时在我自己的应用程序上

更新: 选项卡的数值是 9

So when the tab key is pressed you'd like to give focus to the web browser?

put your code in

private void ("what tab is benig pressed on")_KeyPress(object sender,    KeyPressEventArgs e)
{
    if (e.Keychars == keys.Tab)
    {
        webBrowser.Select();
        webBrowser.Focus();
    }            
}

I think keys.Tab should work if not try googling what the numeric value of the tab key is and put it in place of keys.Tab

where i put " what tab is being press on you'd run the key press on that...not the webBrowser

hope this helps sorry if my not correct i just spend 7 hours on an application of my own

Update: numeric value for tab is 9

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文