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

NumericUpdown with keystrokes

Thread ID:

Created:

Updated:

Platform:

Replies:

25625 Mar 2,2005 02:54 PM UTC Mar 2,2005 09:08 PM UTC WinForms 2
loading
Tags: GridControl
A. Chakravarty "Chak"
Asked On March 2, 2005 02:54 PM UTC

I would like to add the numericupdown type in a cell but instead of clicking on the up/down button, I want touse keystrokes to change the values in the cell in various units of increment or decrement. I want to trap the keystrokes in a numericupdown cell. Thanks in advance Chak

Administrator [Syncfusion]
Replied On March 2, 2005 05:26 PM UTC

If the cell is actively being edited, you can catch keystrokes in CurrentCellControlKeyMessage (it is raised for both KeyUp and KeyDown, so just e.Msg to pick out only one hit. To test what cell you are on, you can check the the type of grid.CurrentCell.Renderer. this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SetCurrent; this.gridControl1.CurrentCellControlKeyMessage += new GridCurrentCellControlKeyMessageEventHandler(gridControl1_CurrentCellControlKeyMessage);
private void grid_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
{
	Keys keyCode = (Keys) ((int)e.Msg.WParam) & Keys.KeyCode;
	if(e.Msg.Msg == 0x100) //WM_KEYDOWN
	{
		Console.WriteLine("WM_KEYDOWN->" + keyCode.ToString());
	}
	else if(e.Msg.Msg == 0x101) //WM_KEYUP
	{
		Console.WriteLine("WM_KEYUP->" + keyCode.ToString());
	}
}

A. Chakravarty "Chak"
Replied On March 2, 2005 09:08 PM UTC

I was catching the keystrokes with the Windows.Forms.KeyEventHandler. However, in NumericUpdown celltypes, when I recompute the values to be anything other than numeric, an exception occurs. When i change the celltype to static, the values are correctly displayed as they were computed with each keystroke. Regards Chak >If the cell is actively being edited, you can catch keystrokes in CurrentCellControlKeyMessage (it is raised for both KeyUp and KeyDown, so just e.Msg to pick out only one hit. To test what cell you are on, you can check the the type of grid.CurrentCell.Renderer. > > >this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SetCurrent; >this.gridControl1.CurrentCellControlKeyMessage += new GridCurrentCellControlKeyMessageEventHandler(gridControl1_CurrentCellControlKeyMessage); > > >
>private void grid_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
>{
>	Keys keyCode = (Keys) ((int)e.Msg.WParam) & Keys.KeyCode;
>	if(e.Msg.Msg == 0x100) //WM_KEYDOWN
>	{
>		Console.WriteLine("WM_KEYDOWN->" + keyCode.ToString());
>	}
>	else if(e.Msg.Msg == 0x101) //WM_KEYUP
>	{
>		Console.WriteLine("WM_KEYUP->" + keyCode.ToString());
>	}
>}
>
> >

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.

Please sign in to access our forum

or the page will be automatically redirected to 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

;