Keep window on top and steal focus in WinForms

后端 未结 5 1614
后悔当初
后悔当初 2020-11-27 16:31

I realize that this would be COMPLETELY bad practice in normal situations, but this is just for a test app that needs to be taking input from a bar code scanner (emulating a

5条回答
  •  Happy的楠姐
    2020-11-27 16:53

    I struggled with a similar problem for quite a while. After much experimentation and guessing, this is how I solved it:

    // Get the window to the front.
    this.TopMost = true;
    this.TopMost = false;
    
    // 'Steal' the focus.
    this.Activate();
    

提交回复
热议问题