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

Grid Grouping control - validation for editable cells

Hi,

I have a text box column in the grid. I want to restrict the textbox to accept only Numeric values. I would also like to put a max length restriction on that column when edited.

Thanks,
Deepa


1 Reply

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


Loader.
Live Chat Icon For mobile
Up arrow icon