JJ
Jisha Joy
Syncfusion Team
September 5, 2008 04:43 AM UTC
Hi Deepa,
We appreciate your interest in SYncfusion Products.
TO restrict the textbox to accept only Numeric values .
This can be achieved by handling the TableControlCurrentCellKeyPress event of Grid GroupingControl. Please refer the code:
this.gridGroupingControl1. += new GridTableControlKeyPressEventHandler(gridGroupingControl1_TableControlCurrentCellKeyPress);
void gridGroupingControl1_TableControlCurrentCellKeyPress(object sender, GridTableControlKeyPressEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo styleInfo = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);
if (styleInfo.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& styleInfo.TableCellIdentity.Column.Name == "ID")
{
if (!char.IsNumber(e.Inner.KeyChar))
e.Inner.Handled = true;
}
}
Put a max length restriction on that column
Please refer the code:
this.gridGroupingControl1.TableDescriptor.Columns["ID"].Appearance.AnyRecordFieldCell.MaxLength = 3;
Please try this and let me know if this helps.
Regards,
Jisha