Hi
VS2017 & Winforms Application
I have a class with the properties of, say FirstName, LastName and Age. Above each property in the class I can define it's position and also the header text to display:
[PropertyOrder(1)],
[DisplayName("First Name")
[Browseable(true)]
public string FirstName {get; set;}
I then create a BindingList<classname> of this class and add several instances to it, the list is then applied to the DataSource of the UltraGrid control.
So my Winform now has a grid on it with 3 columns with the headers of "First Name", "Last Name" and "Age". Because it's a binding list, as soon as the user updates the data / adds new rows, the list is updated, I can then iterate through this list and save the data... All is fine... Except Validation.
So what is the best way to validate these 3 fields.. ?
Can I put [MaxLength(50)] above the two name properties to set the max length and Min/MaxValue on the Age so it's between 0 and 150 ?
I want to validate the data before it's saves to the Database, and get errors because the string is too long or the age is way to high!.
Many thanks
Hello ,
Thank you for posting to our forum.
Yes you are right you can handle the validation at the database level by setting the field length.
Though there are multiple other ways to validate the grid cell value.
Go through these links provided more information about grid cell validation:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=1747
https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/69457/how-to-validate-ultrawingrid-cell-value
https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/33249/wingrid-cell-validation
Please let me know if you need further assistance.