windowsforms-devexpress-dot-xtraeditors-dot-baseedit-7be7a147.md
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.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event QueryProcessKeyEventHandler QueryProcessKey
<DXCategory("Events")>
Public Event QueryProcessKey As QueryProcessKeyEventHandler
The QueryProcessKey event's data class is DevExpress.XtraEditors.Controls.QueryProcessKeyEventArgs.
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.
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;
}
}
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
AddHandler repositoryItemMemoEdit1.QueryProcessKey, AddressOf repositoryItemMemoEdit1_QueryProcessKey
End Sub
Private Sub repositoryItemMemoEdit1_QueryProcessKey(sender As Object, e As DevExpress.XtraEditors.Controls.QueryProcessKeyEventArgs)
If e.KeyData = Keys.Enter Then
e.IsNeededKey = False
End If
End Sub
End Class
See Also