Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 EditingControlWantsInputKey Method
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
IDataGridViewEditingControl..::.EditingControlWantsInputKey Method

Determines whether the specified key is a regular input key that the editing control should process or a special key that the DataGridView should process.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic (Declaration)
Function EditingControlWantsInputKey ( _
    keyData As Keys, _
    dataGridViewWantsInputKey As Boolean _
) As Boolean
Visual Basic (Usage)
Dim instance As IDataGridViewEditingControl
Dim keyData As Keys
Dim dataGridViewWantsInputKey As Boolean
Dim returnValue As Boolean

returnValue = instance.EditingControlWantsInputKey(keyData, _
    dataGridViewWantsInputKey)
C#
bool EditingControlWantsInputKey(
    Keys keyData,
    bool dataGridViewWantsInputKey
)
Visual C++
bool EditingControlWantsInputKey(
    Keys keyData, 
    bool dataGridViewWantsInputKey
)
JScript
function EditingControlWantsInputKey(
    keyData : Keys, 
    dataGridViewWantsInputKey : boolean
) : boolean

Parameters

keyData
Type: System.Windows.Forms..::.Keys
A Keys that represents the key that was pressed.
dataGridViewWantsInputKey
Type: System..::.Boolean
true when the DataGridView wants to process the Keys in keyData; otherwise, false.

Return Value

Type: System..::.Boolean
true if the specified key is a regular input key that should be handled by the editing control; otherwise, false.

An editing control implements this method to determine which input keys should be processed by the control, and which input keys should be processed by the DataGridView.

The EditingControlWantsInputKey method is called by the DataGridView. The DataGridView will pass in true for dataGridViewWantsInputKey when it can process the keyData. If the editing control can let the DataGridView handle the keyData, EditingControlWantsInputKey should return false when dataGridViewWantsInputKey is true. Other implementations of EditingControlWantsInputKey may ignore a dataGridViewWantsInputKey value of true and handle the keyData in the editing control.

The following code example provides an implementation of this member. This example is part of a larger example available in How to: Host Controls in Windows Forms DataGridView Cells.

Visual Basic
Public Function EditingControlWantsInputKey(ByVal key As Keys, _
    ByVal dataGridViewWantsInputKey As Boolean) As Boolean _
    Implements IDataGridViewEditingControl.EditingControlWantsInputKey

    ' Let the DateTimePicker handle the keys listed.
    Select Case key And Keys.KeyCode
        Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, _
            Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp

            Return True

        Case Else
            Return Not dataGridViewWantsInputKey
    End Select

End Function
C#
// Implements the IDataGridViewEditingControl.EditingControlWantsInputKey 
// method.
public bool EditingControlWantsInputKey(
    Keys key, bool dataGridViewWantsInputKey)
{
    // Let the DateTimePicker handle the keys listed.
    switch (key & Keys.KeyCode)
    {
        case Keys.Left:
        case Keys.Up:
        case Keys.Down:
        case Keys.Right:
        case Keys.Home:
        case Keys.End:
        case Keys.PageDown:
        case Keys.PageUp:
            return true;
        default:
            return !dataGridViewWantsInputKey;
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker