varocarbas 덕분에 답을 찾았습니다. 누가 저의 원래 질문 아래에 댓글을 남겼습니다. 내 가정은 CellEndEdit 이벤트가 ProcessCmdKeys() 메서드 호출 다음에 발생하지만 OnKeyPress() 호출 전에 ENTER 키의 우선 순위가 일반 키 (Command 키)보다 높기 때문에 발생한다고 가정합니다. OnKeyPress()를 사용하여 셀이 여전히 EditMode에있는 동안 동작을 변경할 수없는 이유를 설명합니다.
는
DataGridView를에서 ENTER 키를 눌러 다음 발생 어떤 조치를 방지 내가 만든 사용자 정의 된 DataGridView는 아래 볼 수 있습니다 : 경우
Public Class clsModifyDataGridView
Inherits Windows.Forms.DataGridView
''' <summary>
''' Changes the behavior in response to a Command-precedence key press
''' </summary>
''' <returns>True if we handled the key-press, otherwise dependent on default behavior</returns>
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
' Was the ENTER key pressed?
If keyData = Keys.Enter Then ' YES
' DO NOTHING
Return True
End If
' Handle all other keys as usual
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
End Class
누군가 날 수정하시기 바랍니다에 대한 내 가정 호출 시퀀스가 부적절합니다. 또한이 ProcessCmdKey() 오버라이드는 앞서 언급 한 OnKeyPress() 메서드의 재정의를 불필요하게 만든다.
편집 모드에서 일어나는 일에 대해 설명해야하는 유일한 방법은 키를 연결하는 것입니다 (이 상황을 완전히 제어 할 수있는 이벤트가없는 한). 여기에이 문제에 대한 해결책 인 링크가있는 게시물 (C#)이 있습니다. http://stackoverflow.com/questions/2527371/how-can-i-change-what-happens-when-enter- key-is-pressed-a-datagridview – varocarbas
감사합니다, 귀하의 링크를 사용하여 내가 찾고있는 해답을 찾았습니다! –
도움이되어서 기쁘게 생각합니다. – varocarbas