Webbrowser steals focus

前端 未结 7 1817
天命终不由人
天命终不由人 2021-01-06 07:17

I\'m using webbrowser control in my winforms app (c#). And when it is doing automation things, I\'m losing focus control from the window I was working with. Webbrowsers\' fo

7条回答
  •  离开以前
    2021-01-06 07:54

    I was looking at all the other answers to this question and they weren't working for me, but i saw the one about settings Browser.Parent.Enabled = false; i tried so and got an error, so i tried this instead it just came to mind.

    Browser.Parent = new Control();

    Browser.Parent.Enabled = false;

    And now the problem is completely gone, it does not take away focus anymore. I am using the web browser class as a variable, it is not on my form. well this worked for me try it, this seemed to be a 100% solution.

提交回复
热议问题