Click here to Skip to main content
Click here to Skip to main content

How to display or hide standard button cues.

, 18 Nov 2010
Rate this:
Please Sign up or sign in to vote.
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

priyamtheone

India India
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 18 Nov 2010
Article Copyright 2010 by priyamtheone
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid