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.
Unfortunately, activation email could not send to your email. Please try again.

Grid Grouping control - validation for editable cells

Thread ID:

Created:

Updated:

Platform:

Replies:

76397 Sep 4,2008 11:27 AM Sep 5,2008 12:43 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 4, 2008 11:27 AM

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


Jisha Joy [Syncfusion]
Replied On September 5, 2008 12:43 AM

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


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.

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.

;