Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

winforms

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.

like image 317
Chris.C Avatar asked Nov 27 '25 12:11

Chris.C


1 Answers

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.

like image 70
pbotas Avatar answered Nov 30 '25 01:11

pbotas