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

NumericUpdown with keystrokes

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

2 Replies

AD Administrator Syncfusion Team March 2, 2005 12:26 PM

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());
	}
}


AC A. Chakravarty "Chak" March 2, 2005 04:08 PM

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());
>	}
>}
>
> >

Loader.
Live Chat Icon For mobile
Up arrow icon