When we set focus on a standard button by pressing Tab key on the
keyboard or clicking mouse button on it, it displays a cue (a rectangle
with dotted lines). Sometimes it is needed for the cue to not appear
e.g. buttons with vista or windows 7 glossy looks. The cue over such
buttons makes it look too old or win95-ish.
To remove the cue you need to set the ShowFocusCues property of the
button to False. But this property is not directly available to the
programmer. This property is available in the ButtonBase class with
protected access specifier. In order to set this property to false we
need to create a class that inherits from ButtonBase and set this
property explicitly to False.
class CustomButton : System.Windows.Forms.Button
{
protected override bool ShowFocusCues
{
get
{
return false;
}
}
}
More generic class for Button.
class CustomButton : System.Windows.Forms.Button
{
private bool _DisplayFocusCues = true;
protected override bool ShowFocusCues
{
get
{
return _DisplayFocusCues;
}
}
public bool DisplayFocusCues
{
get
{
return _DisplayFocusCues;
}
set
{
_DisplayFocusCues = value;
}
}
}
Using this class you can set DisplayFocusCues at design time too.