Home Forums WinForms controls Xceed Grid for WinForms Setting up of validation by code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16231 |

     Hi,

    I have tried to find any codes to setup the validation provider via code.  However, I failed. 

    The following is the code for setting up my validation provider.  Any help to advise if the following code is the correct way of setting up validation provider?

    The following section declares global variables.

                Dim cellInsertionRow As Xceed.Grid.InsertionCell
                Dim RateInsertionRow As Xceed.Grid.InsertionCell 

                Dim cellDataRow As Xceed.Grid.DataCell
                Dim RateDataRow As Xceed.Grid.DataCell

                Dim Criterion As Xceed.Validation.DataTypeCriterion
                Dim RateCriterion As Xceed.Validation.RangeCriterion

    The following code shows the initialisation code.

                cellDataRow = Me.dataRowTemplate1.Cells(obj.ColumnNames.TAXTYPE.ToString)
                cellDataRow.Initialize(obj.ColumnNames.TAXTYPE.ToString)

                RateDataRow = Me.dataRowTemplate1.Cells(obj.ColumnNames.TAXRATE.ToString)
                RateDataRow.Initialize(obj.ColumnNames.TAXRATE.ToString)

                cellInsertionRow = Me.InsertedRow.Cells(obj.ColumnNames.TAXTYPE.ToString)
                cellInsertionRow.Initialize(obj.ColumnNames.TAXTYPE.ToString)

                RateInsertionRow = Me.InsertedRow.Cells(obj.ColumnNames.TAXRATE.ToString)
                RateInsertionRow.Initialize(obj.ColumnNames.TAXRATE.ToString)

                Criterion = New Xceed.Validation.DataTypeCriterion()
                Criterion.CriterionName = obj.ColumnNames.TAXTYPE.ToString & ” Criterion”
                Criterion.ValidationLevel = Xceed.Validation.ValidationLevel.Automatic
                Criterion.DataType = Xceed.Validation.ValidationDataType.String
                Criterion.CaseSensitive = False
                Criterion.CustomValidationMessages = New Xceed.Validation.CustomValidationMessages

                RateCriterion = New Xceed.Validation.RangeCriterion()
                RateCriterion.CriterionName = obj.ColumnNames.TAXRATE.ToString & ” Criterion”
                RateCriterion.ValidationLevel = Xceed.Validation.ValidationLevel.Automatic
                RateCriterion.DataType = Xceed.Validation.ValidationDataType.Decimal
                RateCriterion.Max = 10.0
                RateCriterion.Min = 0.0
                RateCriterion.Trim = True
                RateCriterion.RequiredField = True
                RateCriterion.CustomValidationMessages = New Xceed.Validation.CustomValidationMessages
                RateCriterion.CaseSensitive = False

                Validator.SetValidationExpression(cellDataRow, Criterion)
                Validator.SetValidationExpression(RateDataRow, RateCriterion)

                Validator.SetValidationExpression(cellInsertionRow, Criterion)
                Validator.SetValidationExpression(RateInsertionRow, RateCriterion)

    Are the codes shown above correctly set out?  Suggestions would be mostly appreciated.

    Imported from legacy forums. Posted by James (had 783 views)

    User (Old forums)
    Member
    Post count: 23064

    May be if you would explain what you want, or what is it that is not working, it would be easier to help you. 🙂

    Imported from legacy forums. Posted by André (had 254 views)

    User (Old forums)
    Member
    Post count: 23064

    Nevermind. I was setting up a grid with validation.  It doesn’t seem to be working smoothly. 

    With the above setting, when validation does fail, then the winbutton would not work properly.  However, regardless of the result of the validation process, when one clicks on the tool button, the program will proceed as follows and throws back an exception. 

    This seems to be the behaviour of the tool button.  I guess I had to find a way around it… or, stop using the tool button altogether.  Please delete this case altogether.  Thanks.

    Imported from legacy forums. Posted by James (had 1461 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.