Skip to main content

RepositoryItem.QueryProcessKey Event

Provides the capability to specify whether the key pressed in the editor is processed by the editor or a container control (GridControl, TreeList, etc.) that displays this editor.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

[DXCategory("Events")]
public event QueryProcessKeyEventHandler QueryProcessKey

Event Data

The QueryProcessKey event's data class is DevExpress.XtraEditors.Controls.QueryProcessKeyEventArgs.

Remarks

The QueryProcessKey event fires when an end-user presses a key in an editor. Handle this event to specify whether the pressed key is processed by the editor or a container control that displays this editor. The BaseEdit.QueryProcessKey event is equivalent to the current event.

The following QueryProcessKeyEventArgs properties provide information specific to this event.

Property Description
KeyData Gets the System.Windows.Forms.Key value that specifies the key to process.
IsNeededKey Indicates whether the key is handled by the editor or the container control. true if the key is processed by the editor; false if the key is processed by the container control.

Example

By default, pressing the Enter key in a MemoEdit causes a carriage return. The following example shows how to handle the RepositoryItem.QueryProcessKey event to prevent this from happening.

In the following example, the RepositoryItem.QueryProcessKey event is handled to set the IsNeededKey parameter to false when the Enter key is pressed. This prevents the MemoEdit control from processing this key. If the MemoEdit control is used as an in-place editor within a container control (e.g., GridControl), as a result, the pressed Enter key will be processed by this container control. The container control will close the active MemoEdit control while saving the changes,.

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        repositoryItemMemoEdit1.QueryProcessKey += repositoryItemMemoEdit1_QueryProcessKey;
    }
    private void repositoryItemMemoEdit1_QueryProcessKey(object sender, DevExpress.XtraEditors.Controls.QueryProcessKeyEventArgs e) {
        if (e.KeyData == Keys.Enter) e.IsNeededKey = false;
    }
}
See Also