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

validate string in ggc

I am using syncfusion ggc 5.2. I want that if user enters a string which is more than 1000 characters the cell should show a error with an error message(error message only when user points to error symbol of cell).
I will be v thankfull if anyone could help me in this.


1 Reply

HA haneefm Syncfusion Team January 2, 2008 11:59 PM UTC

Hi Prabhjeet,

To validate the grid cell string, you need to handle the TableControlCurrentCellValidateString and set the e.Inner.Cancel to true for invalid text. Below are the codes:

void gridGroupingControl1_TableControlCurrentCellValidateString(object sender, GridTableControlCurrentCellValidateStringEventArgs e)
{
Console.WriteLine(e.TableControl.CurrentCell.Renderer.ControlText.Length);
if( e.TableControl.CurrentCell.Renderer.ControlText.Length > 10 )
{
e.Inner.Cancel = true;
FieldDescriptor fd = e.TableControl.Table.CurrentRecordManager.CurrentField;
CurrentRecordProperty prop = e.TableControl.Table.CurrentRecordManager.Properties[ fd ];
prop.Exception = new Exception( "Invalid Text"); //Error Message in a Cell;
MessageBox.Show("Invalid Text"); //Poup Error Message
}

}

Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon