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.

CurrentCellKeyUp event for Virtual Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

47724 Aug 10,2006 01:12 PM Aug 14,2006 02:45 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 10, 2006 01:12 PM

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?


Administrator [Syncfusion]
Replied On August 11, 2006 01:42 AM

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

Administrator [Syncfusion]
Replied On August 11, 2006 10:39 AM

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

Administrator [Syncfusion]
Replied On August 14, 2006 02:45 AM

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

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.

;