Validation

Posted by: kbj on 2 February 2019, 11:00 am EST

    • Post Options:
    • Link

    Posted 2 February 2019, 11:00 am EST

    I am not sure I am getting this right . . .

    in the below example, the cell displays the aquamarine background for an erroneous value only when the value has been entered and then returned into the edit mode. When the cell is not being edited, the background is not aquamarine. Wouldn’t it make more sense for cell background to always be aquamarine? What am I missing?

    
        Dim stylenotify As New FarPoint.Win.Spread.CellStyleNotify()
            stylenotify.InvalidCellStyle.BackColor = Color.Aquamarine
            Dim rvalid As New FarPoint.Win.Spread.RangeValidator()
            rvalid.MaxValue = 10
            rvalid.MinValue = 0
            rvalid.Actions.Add(stylenotify)
            fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), rvalid)
    
    
  • Posted 4 February 2019, 9:25 pm EST

    Hello,

    This is the design behavior with AddValidators method that it works in edit mode. However, if you want to set the color even after exiting the cell if the value isn’t valid then you can use conditional formatting for the same as given below:-

     Dim stylenotify As New FarPoint.Win.Spread.CellStyleNotify()
            stylenotify.InvalidCellStyle.BackColor = Color.Aquamarine
            Dim rvalid As New FarPoint.Win.Spread.RangeValidator()
            rvalid.MaxValue = 10
            rvalid.MinValue = 0
            rvalid.Actions.Add(stylenotify)
            FpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), rvalid)
    
            Dim between As FarPoint.Win.Spread.BetweenValuesConditionalFormattingRule = New FarPoint.Win.Spread.BetweenValuesConditionalFormattingRule(True, 10, False, 20, False)
            between.FirstValue = 0
            between.SecondValue = 10
            between.IsNotBetween = True
            between.BackColor = Color.Aquamarine
            ' Overloading the SetConditionalFormatting Method
            FpSpread1_Sheet1.SetConditionalFormatting(1, 1, 1, 1, True, between)
    

    Hope it helps.

    Thanks,

    Reeva

  • Posted 5 February 2019, 1:17 am EST - Updated 30 September 2022, 5:00 am EST

    Hi Reeva,

    Thanks for your response. I noticed that when using a IconNotify in a validator that the Icon displays even when the cell is not in the edit mode. This provides great feedback to the user that something is wrong in the cell.

    
            'Test if cell string contains 'Test' 
            'display error Icon - background pink
            Dim errorIcon = Icon.FromHandle(My.Resources.warning.GetHicon)
            Dim IconNotify = New IconNotify
            IconNotify.Icon = errorIcon
            IconNotify.IconAlignment = ContentAlignment.TopLeft
            IconNotify.IconTip = "something's wrong here!"
            Dim cnotify As New CellStyleNotify()
            cnotify.InvalidCellStyle.BackColor = Color.Pink
            Dim svalid As New CompareStringValidator()
            svalid.ComparedOperator = CompareStringValidatorOperator.Contains
            svalid.ComparedString = "Test"
            svalid.Actions.Add(iconNotify)
            svalid.Actions.Add(cnotify)
            Book1_Sheet1.AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 2, 1), svalid)
            Book1_Sheet1.Columns(1).Width = 140
            Book1_Sheet1.Rows(1, 2).Height = 50
    
    



    It seems to me it would be logical for all “notifys” persist whether the cell is in edit mode or not without the additional conditional formatting overhead.

    -Kingman

  • Posted 5 February 2019, 5:13 am EST

    As a quick add-on to this thread . . .

    Is there any way to know when the Icon in the above example is clicked? It appears to be in a reserved area when the cell is in edit mode.

  • Posted 6 February 2019, 8:54 pm EST

    Hello,

    We are discussing your issue with our developers and we will get back to you as soon as we hear anything from them.

    Tracking id for your issue is #269853

    Thanks,

    Reeva

  • Posted 10 February 2019, 6:27 pm EST

    Hello,

    Our developers have confirmed that base on current implementation, all style notify will have effect only if the cell is in editing mode. In view mode, only 3 following Notify will take effect:

    IconNotify

    ThreeStateIconNotify

    LineNotify

    Your request is not from the original design/implementation of this feature.

    “Further Is there any way to know when the Icon in the above example is clicked? It appears to be in a reserved area when the cell is in edit mode.”

    Up to this time, there is no way to know. The icon is paint in a separate control which is above Spread control.

    Hope it clarifies.

    Thanks,

    Reeva

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels