How to set/change/remove focus style on a Button in C#?

后端 未结 12 1132
鱼传尺愫
鱼传尺愫 2020-11-28 08:39

I have a couple of buttons of which I modified how they look. I have set them as flat buttons with a background and a custom border so they look all pretty and nothing like

12条回答
  •  暖寄归人
    2020-11-28 09:11

    Another option (although a bit hacktastic) is to attach an event-handler to the button's GotFocus event. In that event-handler, pass a value of False to the button's NotifyDefault() method. So, for instance:

    void myButton_GotFocus(object sender, EventArgs e)
    {
      myButton.NotifyDefault(false);
    }
    

    I'm assuming this will work every time, but I haven't tested it extensively. It's working for me for now, so I'm satisfied with that.

提交回复
热议问题