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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Simulating key presses

Thread ID:





59606 Apr 18,2007 12:46 PM UTC Apr 18,2007 07:14 PM UTC WinForms 3
Tags: GridControl
Miki Watts
Asked On April 18, 2007 12:46 PM UTC

I'm working with GDBG

I'm working with an onscreen keyboard, that is button based, and I want to simulate a key press into the grid.

Since the keyboard is button based, they steal the focus from the grid. The solution that I found was to raise an event from the onscreen keyboard into the grid, and in the grid to do something like this :

void Keyboard_KeyPressed(char key)
Message msg = new Message();
msg.Msg = 0x102;
msg.WParam = (IntPtr) key;

bool handled = CurrentCell.Renderer.RaiseProcessKeyEventArgs(ref msg);

if (handled == false)
CurrentCell.Renderer.ControlText += key;

However, that's quite a nasty bypass, and it doesn't work completely like a regular keypress (for example, column text shows as wrapped in narrow columns when the user presses a key, but not from the keyboard).

Is there standard way to do something like this ?

haneefm [Syncfusion]
Replied On April 18, 2007 03:58 PM UTC

Hi Miki,

Try calling the RaiseCurrentCellControlKeyMessage method to raise key event in a grid. Here is a code snippet

this.gridDataBoundGrid1.RaiseCurrentCellControlKeyMessage( gcem);

Best regards,

Miki Watts
Replied On April 18, 2007 04:08 PM UTC

nope, sorry, it doesn't raise the keypress event now.

Administrator [Syncfusion]
Replied On April 18, 2007 07:14 PM UTC

Just something to try. Comment out the code in your current Keyboard_KeyPressed. Instead, call grid.Focus() and the SendKeys.Send to pass the key onto the grid. After the SendKeys.Send call, you might need to set the focus back to the keyboard control.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon