[英]How Can I Deselect a Button or Redefine the function of the Return Key in Windows Forms?
[英]How to deselect button in Windows Forms
我已經在Windows窗體中創建了自己的最小化按鈕,並像下面的代碼一樣處理Click
事件:
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
this.notifyIcon.Visible = true;
this.notifyIcon.ShowBalloonTip(1000);
不幸的是,當窗口恢復到正常狀態時,此按鈕上有一個選擇:
有什么辦法可以避免這種行為?
提前致謝。
這是避免這種情況的代碼,請嘗試一下:
yourButton.TabStop = false;
yourButton.FlatStyle = FlatStyle.Flat;
yourButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); //Transparent
如果不起作用,請嘗試以下操作:覆蓋ShowFocusCues屬性
protected override bool ShowFocusCues
{
get
{
return false;
}
}
通常有一些控制焦點。
您可以決定應該使用哪個thatcontrol.Focus();
然后添加那個thatcontrol.Focus();
您需要在最小化調用之前添加它:
label1.Focus();
this.WindowState = FormWindowState.Minimized;
但是,為了獲得最佳用戶體驗,imo應當將Focus
放在可見控件上,以便用戶知道自己所在的位置。 (我討厭那些我想開始打字的網頁,但無處可去。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.