VB2010怎么获取鼠标所点击的窗体内的控件的名称和类型?

2024-12-22 09:34:48
推荐回答(2个)
回答1:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim buttonctrl As Button = sender
Label1.Text = sender.GetType.FullName + "," + buttonctrl.Name
End Sub

回答2:

Private Sub Form_Load()
Dim x As Object
For Each x In Form1
Debug.Print x.Name
Next
End Sub