C# 表單 focus 偵測 事件 [C# winform focus EVENT]
C# 表單 focus 偵測 事件 [C# winform focus EVENT]
資料來源: https://www.daniweb.com/programming/software-development/threads/349769/c-winform-getting-loosing-focus
http://kyleap.blogspot.com/2014/01/c-win-formgotfocuslostfocusfocusbutton.html
Code:[ 表單/元件 獲得駐點(焦點)的語法 Object.Focus(); ]
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CS_VPOS { public partial class SysMenu : Form { public SysMenu() { InitializeComponent(); this.GotFocus += new EventHandler(SysMenu_GotFocus);//事件表沒有可以設定 this.LostFocus += new EventHandler(SysMenu_LostFocus); } private void SysMenu_GotFocus(object sender, EventArgs e) { // } private void SysMenu_LostFocus(object sender, EventArgs e)//使用Show顯示才有可能被觸發 { //把SHOW顯示效果變成ShowDialog ~ this.Focus(); this.Close();//失去焦點就關閉視窗 } private void SysMenu_Load(object sender, EventArgs e) { } } }
One thought on “C# 表單 focus 偵測 事件 [C# winform focus EVENT]”
C# 表單 focus 偵測/抓取 焦點 事件 [C# winform focus EVENT]