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

Numeric cell editing

I have a cell, type decimal, I want to limit the input to positive numbers only.

I have tried doing this via NumericUpDown cellType, but I get errors if I input decimals in it.
I have also tried listening to key events - so that I could suppress the minus sign - but the only key event that gets fired on the grid or the renderer is KeyPressed (which I cannot suppress).

Any ideas - this is something that should be obvious and easy - but not with Synconfusion!

Thanks
Sat

1 Reply

AD Administrator Syncfusion Team November 14, 2006 05:47 AM UTC

Hi Sat,

You can use the TextBox celltype and handle the KeyPress event to cancel the non-numeric editing . Kindly refer to sample for details

private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if( e.KeyChar == '.')
{
if( cc.Renderer.ControlText.IndexOf(".") != -1 )
e.Handled = true;
}
else if(!char.IsDigit(e.KeyChar))
e.Handled = true;
}

Sample : http://www.syncfusion.com/Support/user/uploads/gc_7debb28c.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon