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.

restrict max lenght of cell in ggc

Thread ID:

Created:

Updated:

Platform:

Replies:

70819 Jan 3,2008 01:03 AM Jan 3,2008 01:52 PM Windows Forms 1
loading
Tags: GridControl
abc
Asked On January 3, 2008 01:03 AM

i am using syncfusion ggc. i want to restrict the string entered by user to max 100 character. I mean user should not be able to type more than 100 characters. I am using the following code which is not working.

GridStyleInfo colStyleInfo = this.gridControl1.ColStyles[1];
colStyleInfo.MaxLength = 5;

One more thing that my editable cell is of type "GridListControl"

this.ggc.TableDescriptor.Columns["colName"].Appearance.AnyRecordFieldCell.CellType = "GridListControl";



haneefm [Syncfusion]
Replied On January 3, 2008 01:52 PM

Hi Prabhjeet,

The GridStyleInfo.MaxLength properly is only used with the TextBox cell type.

For other cell types, you would have to handle things yourself. A straight-forward way of doing this is to handle the TableControlCurrentCellKeyPress event and set e.Inner.Handled if the current string is to long. Below is a code snippet.

private void gridGroupingControl1_TableControlCurrentCellKeyPress(object sender, GridTableControlKeyPressEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if (cc.Renderer.ControlText.Length > 100)
{
e.Inner.Handled = true;
}
}

Let me know if something like this will not work for you.

Best regards,
Haneef


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.

;