Skip to main content

BaseEdit.QueryProcessKey Event

Provides ability 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

Assembly: DevExpress.XtraEditors.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

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 the editor. Handle this event to specify whether the pressed key is processed by the editor or the container control. The editor’s QueryProcessKey event is equivalent to the RepositoryItem.QueryProcessKey event available via the BaseEdit.Properties object. See RepositoryItem.QueryProcessKey to learn more.

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