网络浏览器焦点问题 [英] web browser focus problem

查看:244
本文介绍了网络浏览器焦点问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在winform中使用网页浏览器。

似乎在左键单击网页浏览器时会从表单中获取焦点,我无法将焦点重新放回到表单中。我试过了:this.Focuse(),this.Acticate(),甚至尝试将焦点设置为表单中的任何标签或文本框,但没有任何帮助。我无法从浏览器中释放焦点..

I'm using web browser inside winform.
seems that when left click the web browser it takes the focuse from the form, and i can't get the focus back to the form. i've tried: this.Focuse(), this.Acticate(), even tried to set the focus to any label or textbox in the form, but nothing helped. i can't release the focus from the browser..

推荐答案

你好



我试过这种方式而且我知道它并不完美但是它的工作原理



Hello

I tried this way and I know it's not flawless but it works:

this.MyBrowser.Visible = false;
this.Focus();
this.MyBrowser.Visible = true;





更好的方法是:

使用Panel作为WebBrowser的父级:



A better way is:
Use a Panel as the parent of the WebBrowser:

MyPanel.Enabled = false;
this.Focus();
MyPanel.Enabled = true;


myrowser.Parent = this;



将重点关注形式。
myrowser.Parent = this;

will gives focus to form.


这篇关于网络浏览器焦点问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆