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.

Control in the grid is moved to the next cell when Enter key is pressed.

Thread ID:

Created:

Updated:

Platform:

Replies:

48148 Aug 21,2006 09:36 AM Aug 22,2006 01:39 AM Windows Forms 2
loading
Tags: GridControl
Ravi
Asked On August 21, 2006 09:36 AM

Hi,

My windows form contains DataBoundGrid and few buttons. I have assigned one of the button in the form as "AcceptButton" property of the form. When I press ENTER key while the control is focused on one of the gridcell, the control is moved to the next cell of the grid instead of performing accept button click event. How can I invoke AcceptButton click event, when an Enter key is pressed.

Thanks,
Ravi.

Administrator [Syncfusion]
Replied On August 22, 2006 12:34 AM

Hi Ravi,

To raise the click event of the button when the ENTER key is pressed, you need to handle the CurrentCellKeyDown event to call the PerformClick() method for AcceptButton(windows Button Control).

private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyData == Keys.Enter )
{
e.Handled = true;

//For Normal Windows Button Control
AcceptButton1.PerformClick();

//For GridPushbutton celltype.
GridPushButtonCellRenderer cr = this.gridDataBoundGrid1.CurrentCell.Renderer as GridPushButtonCellRenderer;
if( cr != null)
{
gridDataBoundGrid1_PushButtonClick( sender,null);
}
}
}

private void gridDataBoundGrid1_PushButtonClick(object sender, GridCellPushButtonClickEventArgs e)
{ MessageBox.Show("Clicked"); }

Let me know if this helps.
Best Regards,
Haneef

Ravi
Replied On August 22, 2006 01:39 AM

Thanks Haneef, It works. I have migrated my code from Syncfusion 1.6 version to 4.2 version, with the old version without using your workaround code it works.

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.

;