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
close icon

How do I validate user entry to a Grid.Grouping?

Our cell is integer value and the user entered a value bigger than int32 (ie 123456789012), they will get a dialog saying "123456789012 is not a valid value for Int32".  How do suppress this dialog or validate user's input?


1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team August 16, 2014 02:31 PM UTC

Hi Tuan,

 

Thank you for your interest in Syncfusion products.

 

If you want to validate the user input for Int32 in a grid, you can use the ‘Int32.TryParse()’ method. It Converts the string representation of a number to its 32-bit signed integer equivalent. Please refer the below code,

 

Code Snippet[C#]:-

 

            this.gridGroupingControl1.TableModel[5, 3].CellType = GridCellTypeName.TextBox;

            this.gridGroupingControl1.TableModel[5, 3].Text = "123456789012";

            String s = (this.gridGroupingControl1.TableModel[5, 3].Text).ToString();

            int count = s.Length;

            String sd = this.gridGroupingControl1.TableModel[5, 3].Text;           

            int number2;

            bool result = Int32.TryParse(this.gridGroupingControl1.TableModel[5, 3].Text, out number2);

            if(result == false)

            {                

                 for(int i = count-1 ;i > 9 ;i--)

                 {             

                    sd = sd.Remove(i);

                    this.gridGroupingControl1.TableModel[5, 3].Text = sd;

                }

                MessageBox.Show("Not enter more than Int32 Value");

            }

            this.gridGroupingControl1.TableDescriptor.Columns["I3"].Appearance.AnyRecordFieldCell.MaxLength = sd.Length;

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: setMaxValue_19aa960b.zip

Loader.
Live Chat Icon For mobile
Up arrow icon