Click here to Skip to main content
11,637,415 members (59,532 online)
Click here to Skip to main content

Tagged as

How to display or hide standard button cues.

, 18 Nov 2010 CPOL 7.9K 3
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)

Share

About the Author

priyamtheone
India India
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionThank you Pin
N. Henrik Lauridsen20-Apr-15 9:01
memberN. Henrik Lauridsen20-Apr-15 9:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150728.1 | Last Updated 18 Nov 2010
Article Copyright 2010 by priyamtheone
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid