[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)] internal static extern IntPtr GetFocus(); ///获取 当前拥有焦点的控件 private Control GetFocusedControl() { Control focusedControl = null; IntPtr focusedHandle = GetFocus(); if (focusedHandle != IntPtr.Zero) focusedControl = Control.FromChildHandle(focusedHandle); return focusedControl; }