I have a form just with a textbox and a datagridview. I would like when user pressed an arrow (up/down) it browses through datagridview and when user pressed any other key it sends to textbox.
It's not working, when datagridview has focus and user press a letter key, it changes focus to textbox, but no text is sent.
My code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Down Or keyData = Keys.Up Then
grid.Focus()
Return MyBase.ProcessCmdKey(msg, keyData)
ElseIf Not Me.ActiveControl.Equals(txtFiltro) Then
Me.ActiveControl = txtFiltro
txtFiltro.Focus()
txtFiltro.Select()
Return MyBase.ProcessCmdKey(msg, keyData)
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
The key is sent before change focus... :(
Aucun commentaire:
Enregistrer un commentaire