2013-01-16 245 views
5
的藍色大綱

可能重複:
How to set/change/remove focus style on a Button in C#?刪除按鈕

有沒有一種方法,以消除當按鈕被按下藍色大綱按下/ /激活?

下面是截圖:

Blue outlining

有什麼辦法來隱藏它?我正在使用C#和winforms。

+0

我很確定有一個.IsActive或.IsSelected屬性,你可能會設置爲false – RhysW

+0

如果你想隱藏「焦點」風格,你可能不太擔心可訪問性的要求,因此不關心關於鍵盤兼容性。您可以改爲使用自定義繪畫和對「OnClick」事件的響應的面板或其他控件。 – Snixtor

+0

@RhysW沒有。 –

回答

2

從重複的問題

public class NoFocusCueButton : Button 
{ 
    public NoFocusCueButton() : base() 
    { 
     InitializeComponent(); 

     this.SetStyle(ControlStyles.Selectable, false); 
    } 

    protected override bool ShowFocusCues 
    { 
     get 
     { 
      return false; 
     } 
    } 
} 
1

創建一個新類和繼承類Button,如

public class OnetsButton : Button 
{ 
    public OnetsButton() 
    { 
     this.SetStyle(ControlStyles.Selectable, false); 
    } 
} 
+0

就夠了。它很簡單,但不是更多 – harveyt

0

同化的答案我有一個解決方案,現在,它不是很性感,但它的作品。 我剛剛在窗體中添加了一個不可見的按鈕,現在每次點擊一個按鈕,我都選擇不可見的按鈕。適用於我。