DataGridView.ProcessRightKey(Keys) DataGridView.ProcessRightKey(Keys) DataGridView.ProcessRightKey(Keys) DataGridView.ProcessRightKey(Keys) Method


오른쪽 화살표 키를 처리합니다.Processes the RIGHT ARROW key.

 bool ProcessRightKey(System::Windows::Forms::Keys keyData);
protected bool ProcessRightKey (System.Windows.Forms.Keys keyData);
member this.ProcessRightKey : System.Windows.Forms.Keys -> bool
Protected Function ProcessRightKey (keyData As Keys) As Boolean

매개 변수

Keys Keys Keys Keys

처리할 키를 하나 이상 나타내는 Keys 값의 비트 조합입니다.A bitwise combination of Keys values that represents the key or keys to process.


해당 키가 처리되었으면 true이고, 그렇지 않으면 false입니다.true if the key was processed; otherwise, false.


오른쪽 화살표 키로 인해 컨트롤이 편집 모드로 들어가지만 새로운 현재 셀의 EditType 속성이 Control에서 파생되어 IDataGridViewEditingControl을 구현하는 클래스를 나타내지 않는 경우The RIGHT ARROW key would cause the control to enter edit mode, but the EditType property of the new current cell does not indicate a class that derives from Control and implements IDataGridViewEditingControl.

이 작업을 수행하면 셀 값이 커밋되거나 편집 모드로 전환되지만 데이터 소스의 오류 때문에 해당 작업이 수행되지 않으며 DataError 이벤트에 대한 처리기가 없거나 처리기가 ThrowException 속성을 true로 설정했습니다.This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the DataError event or the handler has set the ThrowException property to true.


다음 코드 예제에서 ENTER 키의 동작을 변경 하는 방법에 설명를 DataGridView 서브 클래스를 재정의 하 여 합니다 ProcessDataGridViewKeyProcessDialogKey 메서드.The following code example demonstrates how to change the behavior of the ENTER key in a DataGridView subclass by overriding the ProcessDataGridViewKey and ProcessDialogKey methods. 예제에서는 ENTER 키에는 오른쪽 화살표 키를 쉽게 사용자 데이터의 단일 행에 여러 셀을 편집 하는 것과 같습니다.In the example, the ENTER key has the same behavior as the RIGHT ARROW key, making it easier for a user to edit multiple cells in a single row of data.

public class CustomDataGridView : DataGridView
        Window = System.Security.Permissions.UIPermissionWindow.AllWindows)]
    protected override bool ProcessDialogKey(Keys keyData)
        // Extract the key code from the key value. 
        Keys key = (keyData & Keys.KeyCode);

        // Handle the ENTER key as if it were a RIGHT ARROW key. 
        if (key == Keys.Enter)
            return this.ProcessRightKey(keyData);
        return base.ProcessDialogKey(keyData);

        System.Security.Permissions.SecurityAction.LinkDemand, Flags = 
    protected override bool ProcessDataGridViewKey(KeyEventArgs e)
        // Handle the ENTER key as if it were a RIGHT ARROW key. 
        if (e.KeyCode == Keys.Enter)
            return this.ProcessRightKey(e.KeyData);
        return base.ProcessDataGridViewKey(e);
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


비관리 코드를 호출 합니다.for calling unmanaged code. 요청 값: LinkDemand합니다.Demand value: LinkDemand. 권한 값: UnmanagedCodePermission value: UnmanagedCode

적용 대상

추가 정보