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

Enter key behavior in GDBG

Hi, i'm using a GridDataBoundGrid and a have detected a strange behavior: when i push enter the CurrentCell moves to the right and KeyPress event is fired, the problem is that when KeyPress is executed CurrentCell is already the next cell (the one to the right).

How can i know (inside KeyPress event) that the enter key was actually pressed when in previous cell?


Thak you
Borja

1 Reply

AD Administrator Syncfusion Team November 28, 2006 10:10 AM UTC

Hi Borja,

You can handle the CurrentCellKeyDown event and get the EnterKey ColIndex of the grid. Then check the LastKeyDown ColIndex to CurrentCell.ColIndex in CurrentCellKeyPress event. Here is a code snippet to show this.

int iLastKeyDownColIndex = -1;
private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{ iLastKeyDownColIndex = this.gridDataBoundGrid1.CurrentCell.ColIndex;}

private void gridDataBoundGrid1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
if( (int)e.KeyChar == 13)
{
if( this.gridDataBoundGrid1.CurrentCell.ColIndex != +iLastKeyDownColIndex)
MessageBox.Show("EnterKey pressed in previous CurrentCell");
}
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon