Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Customizing Interaction in Cells / Using Validation / Using Validation in Cells / Using a Value Comparison Validator
In This Topic
    Using a Value Comparison Validator
    In This Topic

    You can create a validator that compares a cell value to other values. You can compare DateTime, TimeSpan, or Decimal type (Numeric) values.

    A validation error occurs if the value is not valid. You can also create an action, such as adding a text tip to the cell, that lets the user know the value is invalid.

    Use the CompareValueValidator class to create the validator. Specify a notification type such as TipNotify. Then use the AddValidators method to add the validator to a cell range.

    The following image displays the tip notification for an invalid value.

    Spreadsheet displaying a validation error for showing an invalid value

    Using Code

    The following example displays an icon if you type a value less than 5.

    CS
    Copy Code
    //Type a value in cell 1,1
    FarPoint.Win.Spread.TipNotify tnote = new FarPoint.Win.Spread.TipNotify();
    tnote.ToolTipText = "Greater than 5";
    tnote.ToolTipTitle = "Error";
    tnote.ToolTipIcon = ToolTipIcon.Error;
    FarPoint.Win.Spread.CompareValueValidator compare = new FarPoint.Win.Spread.CompareValueValidator();
    compare.ComparedOperator = FarPoint.Win.Spread.ValidateComparisonOperator.GreaterThan;
    compare.ComparedValue = 5;
    compare.Actions.Add(tnote);
    fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), compare);
    
    VB
    Copy Code
    'Type a value in cell 1,1
    Dim tnote As New FarPoint.Win.Spread.TipNotify()
    tnote.ToolTipText = "Greater than 5"
    tnote.ToolTipTitle = "Error"
    tnote.ToolTipIcon = ToolTipIcon.Error
    Dim compare As New FarPoint.Win.Spread.CompareValueValidator()
    compare.ComparedOperator = FarPoint.Win.Spread.ValidateComparisonOperator.GreaterThan
    compare.ComparedValue = 5
    compare.Actions.Add(tnote)
    fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), compare)
    
    See Also