一樓的方法比較巧妙,不過樓上的好像不行
創(chuàng)新互聯(lián)公司自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都網(wǎng)站制作、網(wǎng)站設計網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元渭城做網(wǎng)站,已為上家服務,為渭城各地企業(yè)和個人服務,聯(lián)系電話:028-86922220
最完善的方法當然做鍵盤勾子
簡單點的,就在Form的KeyDown屬性里做就OK了
也要把窗口的keypreview設為True,然后粘貼下面的代碼:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if keycode=vbkeyf3 then check1.value=check1.value xor 1
End Sub
就一句
自己做個試驗就行了:
Public?Class?Form1
'?在窗體上放個?Label1
Private?Sub?Form1_KeyDown(ByVal?sender?As?Object,?ByVal?e?As?System.Windows.Forms.KeyEventArgs)?Handles?Me.KeyDown
Lable1.Text?=?"KeyCode=?"??e.KeyCode.ToString??vbCrLf
Lable1.Text?=?"KeyData=?"??e.KeyData.ToString??vbCrLf
Lable1.Text?=?"KeyValue=?"??e.KeyValue.ToString
End?Sub
End?Class
運行起來,自己按鍵盤試試就知道了。
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler Label1.MouseEnter, AddressOf LabelMouseEnter
AddHandler Label2.MouseEnter, AddressOf LabelMouseEnter
AddHandler Label1.MouseLeave, AddressOf LabelMouseLeave
AddHandler Label2.MouseLeave, AddressOf LabelMouseLeave
AddHandler Label1.MouseDown, AddressOf LabelMouseDown
AddHandler Label2.MouseDown, AddressOf LabelMouseDown
End Sub
Private Sub LabelMouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
Dim c As Label = DirectCast(sender, Label)
c.BackColor = Color.DodgerBlue
End Sub
Private Sub LabelMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim c As Label = DirectCast(sender, Label)
Form1.TextBox1.Text = c.Text
End Sub
Private Sub LabelMouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)
Dim c As Label = DirectCast(sender, Label)
c.BackColor = SystemColors.Control
End Sub
End Class