Home > Net >  How to apply focus visual style for a button without actually focusing it?
How to apply focus visual style for a button without actually focusing it?

Time:08-02

Trying to get a similar effect as the Windows Run dialog. The input box is focused and taking input, and the "OK" button also gets the focused border(but not actually focused). I can't find a way to set button's visual style properly...

C# Winform, .net 4.5(higher version is also OK).

enter image description here.

CodePudding user response:

The property you're looking for is AcceptButton on the form it self. Select the okButton on the form AcceptButton property to make it the default action on Enter keypress.

You also have a similar action for the CancelButton that triggers on Escape keypress.

  • Related