懒人的懒方法之-回车跳转大法
在实际软件开发过程中..经常碰到回车跳转到下一个控件上.
数量少还没什么,可以如下操作,Handles 后把其它控件也加上就行了...
1 Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
2 If e.KeyChar = Chr(13) Then
3 e.Handled = True
4 Me.SelectNextControl(sender, True, True, True, True)
5 End If
6 End Sub
2 If e.KeyChar = Chr(13) Then
3 e.Handled = True
4 Me.SelectNextControl(sender, True, True, True, True)
5 End If
6 End Sub
如果来个十几二十个..一个一个去加也烦...那就来看看这个吧
1 Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
2 If keyData = Keys.Enter Then
3 If Me.ActiveControl.GetType.GetHashCode.ToString = "2068314800" Then
4 Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
5 End If
6 End If
7 End Function
8
2 If keyData = Keys.Enter Then
3 If Me.ActiveControl.GetType.GetHashCode.ToString = "2068314800" Then
4 Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
5 End If
6 End If
7 End Function
8
其中Me.ActiveControl.GetType.GetHashCode.ToString = "2068314800" 是文本框