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.
Unfortunately, activation email could not send to your email. Please try again.

Weird enter/esc key handling

Thread ID:

Created:

Updated:

Platform:

Replies:

17704 Aug 13,2004 12:20 PM Aug 13,2004 01:23 PM Windows Forms 2
loading
Tags: GridControl
Daniel Chait
Asked On August 13, 2004 12:20 PM

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?

Daniel Chait
Replied On August 13, 2004 12:22 PM

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.

Administrator [Syncfusion]
Replied On August 13, 2004 01:23 PM

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);
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;