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

Weird enter/esc key handling

I placed a GDBG on a modal dialog box with an OK and Cancel button (the Form''s .AcceptButton and .CancelButton are set accordingly). When I''m moving around in the Grid, the Grid seems to take the Enter and Esc keys (ie Enter moves to the next cell and Esc does nothing). However, I have a column of type "ComboBox" and here''s the problem. When the dropdown is shown, the user arrows down to their choice and hits Enter, instead of just making hte choice, the Dialog''s OK button is clicked. Likewise for Esc, it doesn''t just close the dropdown, it actually his the form''s CancelButton. Ideas?

2 Replies

DC Daniel Chait August 13, 2004 04:22 PM UTC

Following up, it''s not only in the ComboBox that is a problem. In a normal textbox field, hitting Esc doesn''t cause a canceledit to happen, instead it closes the Dialog.


AD Administrator Syncfusion Team August 13, 2004 05:23 PM UTC

You can try to handle this by overriding ProcessDialogKey in a derived grid.
public class MyGridDataBoundGrid : GridDataBoundGrid
{
	protected override bool ProcessDialogKey(Keys keyData)
	{
		if(keyData == Keys.Enter)
		{
			this.CurrentCell.EndEdit();
			this.CurrentCell.MoveRight();
			return true;
		}
		if(keyData == Keys.Escape)
		{
			this.CurrentCell.CancelEdit();
			return true;
		}
		return base.ProcessDialogKey (keyData);
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon