Bonjour,

dans un datagridview , je souhaite que la touche 'enter' fonctionne comme la fleche de doite ou la touche 'tab', c'est a dire qu'elle passe à la celulle suivante et non pas à la ligne suivante.

Pour cela j'ai creer dans mon projet la classe suivante herite de datagrid view :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
Public Class CustomDataGridView
 
    Inherits DataGridView
 
    <System.Security.Permissions.UIPermission(System.Security.Permissions.SecurityAction.LinkDemand, _
    Window:=System.Security.Permissions.UIPermissionWindow.AllWindows)> _
    Protected Overrides Function ProcessDialogKey( _
          ByVal keyData As Keys) As Boolean
 
        ' Extract the key code from the key value. 
        Dim key As Keys = keyData And Keys.KeyCode
 
        ' Handle the ENTER key as if it were a RIGHT ARROW key. 
        If key = Keys.Enter Then
            Return Me.ProcessRightKey(keyData)
        End If
 
        Return MyBase.ProcessDialogKey(keyData)
 
    End Function
 
    <System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, _
    Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Protected Overrides Function ProcessDataGridViewKey( _
        ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
 
        ' Handle the ENTER key as if it were a RIGHT ARROW key. 
        If e.KeyCode = Keys.Enter Then
            Return Me.ProcessRightKey(e.KeyData)
        End If
 
        Return MyBase.ProcessDataGridViewKey(e)
 
    End Function
 
 
End Class
Pourtant la touche 'enter' passe toujours à la ligne suivante. J'ai l'impression que cette classe n'est pas gérée.
Merci d'avance pour votre aide