DataGridView.ProcessRightKey(Keys) Yöntem

Tanım

SAĞ OK tuşunu işler.

protected:
 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

Parametreler

keyData
Keys

İşlenmek üzere Keys anahtarı veya anahtarları temsil eden değerlerin bit düzeyinde birleşimi.

Döndürülenler

true anahtar işlendiyse; aksi takdirde , false.

Özel durumlar

SAĞ OK tuşu denetimin düzenleme moduna girmesine neden olur, ancak EditType yeni geçerli hücrenin özelliği öğesinden Control türetilen ve uygulayan IDataGridViewEditingControlbir sınıfı göstermez.

Bu eylem bir hücre değeri işler veya düzenleme moduna geçer, ancak veri kaynağındaki bir hata eylemi engeller ve olay için DataError işleyici yoktur veya işleyici özelliği olarak trueayarlamıştırThrowException.

Örnekler

Aşağıdaki kod örneği, ve ProcessDialogKey yöntemlerini geçersiz kılarak bir DataGridView alt sınıftaki ENTER anahtarının ProcessDataGridViewKey davranışının nasıl değiştireceğini gösterir. Örnekte, ENTER tuşu SAĞ OK tuşuyla aynı davranışa sahiptir ve kullanıcının tek bir veri satırında birden çok hücreyi düzenlemesini kolaylaştırır.

public class CustomDataGridView : DataGridView
{
    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);
    }

    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

Şunlara uygulanır

Ayrıca bkz.