首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

关于光标位置解决思路

2012-02-19 
关于光标位置form中有10多个textbox,如何判断光标在哪个textbox上啊?代码怎么写?[解决办法]VB.NET code#Re

关于光标位置
form中有10多个textbox,如何判断光标在哪个textbox上啊?代码怎么写?

[解决办法]

VB.NET code
#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

热点排行