关于光标位置
form中有10多个textbox,如何判断光标在哪个textbox上啊?代码怎么写?
[解决办法]
#Region "" <DllImport("user32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Winapi)> _ Friend Shared Function GetFocus() As IntPtr End Function ''' <summary> ''' 获得当前获得焦点的控件 ''' </summary> ''' <returns></returns> Private Function GetControl() As Control Dim fsControl As Control = Nothing Dim fshandle As IntPtr = GetFocus() If fshandle <> IntPtr.Zero Then fsControl = Control.FromHandle(fshandle) End If Return fsControl End Function Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick Me.Text = "当前焦点控件名称:" + GetControl.Name End Sub#End Region
[解决办法]
Me.ActiveControl.Name