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

CurrentCellKeyUp event for Virtual Grid

Hi,
I have a virtual grid.

One of my application requirements is that users can press F8 on any row for a specific column and trigger a separate dialog which allows them to perform some auto-population for other cells in that row. The column is a normal textbox with no restrictions.

I created a handler for the CurrentCellKeyUp event but it is not being called for any regular characters (alphanumeric, typographic). I have only been able to trigger it with keys such as backspace and tab. Function keys are likewise ignored.

Is there some setting I need to check?


3 Replies

AD Administrator Syncfusion Team August 11, 2006 05:42 AM UTC

Hi Rich,

You can try handling the CurrentCellKeyPress event, this gets fired for every keystroke in a cell. To catch the functionkeys, CurrentCellKeyDown event can be handled, but this will not fire when the cell is in edit mode. So, to catch the functionkeys whether or not a cell is being edited, you can derive the grid and override ProcessCmdKey.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.F8)
{
Console.WriteLine("Function Key F8 pressed");
return true;
}
return base.ProcessCmdKey (ref msg, keyData);
}
private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine( e.KeyChar );
}

Let me know if you have any further questions.
Regards,
Rajagopal


AD Administrator Syncfusion Team August 11, 2006 02:39 PM UTC

Hi again Rajagopal,

Ack! I don''t want to go the override route yet if I don''t have to. I went down that road with half the controls in System.Windows.Forms. But I thought of a different way that may work:

I''m going to define a KeyUp event handler for the form itself to capture the F8. If the ActiveControl is the Grid (or more likely one of the Grid controls like a Grid TextBox or whatever), I''m going to then check the column index on the CurrentCell to see if it is my lookup column. If it is, I''ll proceed from there.

Your thoughts?



>Hi Rich,

You can try handling the CurrentCellKeyPress event, this gets fired for every keystroke in a cell. To catch the functionkeys, CurrentCellKeyDown event can be handled, but this will not fire when the cell is in edit mode. So, to catch the functionkeys whether or not a cell is being edited, you can derive the grid and override ProcessCmdKey.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.F8)
{
Console.WriteLine("Function Key F8 pressed");
return true;
}
return base.ProcessCmdKey (ref msg, keyData);
}
private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine( e.KeyChar );
}

Let me know if you have any further questions.
Regards,
Rajagopal


AD Administrator Syncfusion Team August 14, 2006 06:45 AM UTC

Hi,

To get the cell control to use the functional keys, try handling the CurrentCellControlKeyMessage event.

//Form Load.....
this.gridControl1.CurrentCellControlKeyMessage +=new GridCurrentCellControlKeyMessageEventHandler(gridControl1_CurrentCellControlKeyMessage);

private void gridControl1_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
{
Keys keyCode = (Keys)((int)e.Msg.WParam) & Keys.KeyCode;
if(keyCode == Keys.F8)
{
e.CallBaseProcessKeyMessage = false;
e.CallProcessKeyPreview = false;
Console.WriteLine("Function Key F8 pressed");
}
}

This event is called from current cell control''s ProcessKeyMessage method and gives you a chance to modify the default behavior of this method. Be aware that this a very implementation-specific method and you should only handle this event if KeyDown,KeyUp,CurrentCellKeyDown or CurrentCellKeyUP events are not good enough.

Let me know if this helps.
Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon