Windows requires a click to activate a window before a second click will select a button. How can I change this?

后端 未结 4 1710
一向
一向 2021-02-13 03:26

My application is a C# Windows Forms Application and .Net somehow makes the default behavior of my main menu bar and tool strip buttons to be that you have to first click on my

4条回答
  •  轮回少年
    2021-02-13 04:29

    easy and clean solution

    public class MyToolStrip : System.Windows.Forms.ToolStrip
    {
        protected override void OnMouseEnter(EventArgs e)
        {
            if (this.CanFocus && !this.Focused)
                this.Focus();
    
            base.OnMouseEnter(e);
        }
    }
    

提交回复
热议问题