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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

restrict max lenght of cell in ggc

Thread ID:

Created:

Updated:

Platform:

Replies:

70819 Jan 3,2008 06:03 AM UTC Jan 3,2008 06:52 PM UTC WinForms 1
loading
Tags: GridControl
abc
Asked On January 3, 2008 06:03 AM UTC

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 06:52 PM UTC

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon

;