We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Allow Keys.Enter to pass through

Using Essential Suite 1.6.1.8 I've set KeyPreview on the form that contains a GridDataBoundGrid to true and I'm kind of surprised that my override of ProcessDialogKey is not called when the grid is the active control. What am I doing wrong here? My goal is to be notified when Enter is pressed so that I can open another form to edit the current row. Thanks, Sean

2 Replies

AD Administrator Syncfusion Team November 14, 2003 06:22 AM

You can catch the keys in ProcessKeyPreview. You would want to check for the enter key and for the m.Msg value as this can possibly be hit multiple times (KeyDown, KeyPress, KeyUp).
protected override bool ProcessKeyPreview(ref Message m)
{
	bool enter = (((Keys)m.WParam.ToInt32()) & Keys.Enter) == Keys.Enter;
	if(enter)
	{
		Console.WriteLine(m);
	}
	return base.ProcessKeyPreview(ref m);
}
If you add a Windows Forms DataGrid to your form, you will also see that ProcessDialogKey is not hit for that control either. I think the reason is that the it is really the embedded controls like TextBoxes that have the input focus at this point.


AD Administrator Syncfusion Team November 14, 2003 12:06 PM

Try also setting grid.WantEnterKey = false; Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon