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.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

117105 Aug 12,2014 06:10 PM Aug 16,2014 10:31 AM Windows Forms 1
loading
Tags: GridGroupingControl
Tuan Lam
Asked On August 12, 2014 06:10 PM

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?


Muthukumar Kalyanasundaram [Syncfusion]
Replied On August 16, 2014 10:31 AM

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

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.

;