[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)] internal static extern IntPtr GetFocus(); private Control GetFocusedControl()
{ Control focusedControl = null; // To get hold of the focused control: IntPtr focusedHandle = GetFocus(); if (focusedHandle != IntPtr.Zero) // Note that if the focused Control is not a .Net control, then this will return null. focusedControl = Control.FromHandle(focusedHandle); return focusedControl; }
{ Control focusedControl = null; // To get hold of the focused control: IntPtr focusedHandle = GetFocus(); if (focusedHandle != IntPtr.Zero) // Note that if the focused Control is not a .Net control, then this will return null. focusedControl = Control.FromHandle(focusedHandle); return focusedControl; }
解决方案 »
- 用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联
- c# winform中怎么实现文本框自动补全功能
- 为什么我获的外网IP地址少一位数呢?请帮帮忙
- Setup Factory 集成.netframework2.0打包问题
- 把记录集添加到数据库。。请问怎么解决~~
- 让老人笑话的简单问题,来者有分!
- 请教一个C#查询的应用程序问题?急用?
- Delegate 比 反射快的根本原因是什么?
- Thread join() 追加的参数Millonseond 有何用处?
- >>>>>帮忙翻译为E文,包括代码的中文
- 当有缺失值时怎么处理?
- WWF工作流自带持续化功能,我能将其配置成Oralce数据库吗?
focusedControl = Control.FromHandle(focusedHandle); 获得焦点的控件
{ Control focusedControl = null; //设置为空 // To get hold of the focused control: IntPtr focusedHandle = GetFocus(); //getfocus()获得焦点 if (focusedHandle != IntPtr.Zero) // Note that if the focused Control is not a .Net control, then this will return null. focusedControl = Control.FromHandle(focusedHandle); return focusedControl;