Validation on Spreadsheet

3 posts, 0 answers
  1. john
    john avatar
    4 posts
    Member since:
    Sep 2008

    Posted 05 Mar 2015 Link to this post

    I have a spreadsheet control I am going to use for data input.  Some cells will need data validation which will pop up a message about the error, and put the red circle around it.  I have the spreadsheet control on the form and set my Imports statements, I do not have a ribbon bar on the form.  We do not want to allow the users to change the form, just input data.  When I put in the following line:

    Dim context as new NumberDataValidationRuleContext...

    I get type not defined.  I will need to apply different rule types to different cells, some whole numbers, some decimals, some letters all with ranges. For example 8-12 for hole numbers, .5-3.0 for decimal, A-B for letters. 

    I looked through the documentation and must have missed something.  How do I apply Validation to cells to ensure they are within the ranges?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 09 Mar 2015 Link to this post

    Hello John,

    The code snippets from the documentation of the Data Validation feature should be fully functional as long as the following has been fulfilled:
    1. All required assembly references have been added to the project.
    2. The Telerik.Windows.Documents.Spreadsheet.Model.DataValidation namespace has been added.

    Additionally, note that the feature was introduced in the most recent Q1 2015 release, so the respective classes are not available in versions prior it.

    The below snippet will apply a whole number rule to the (0,0) cell in the active worksheet of a RadSpeadsheet control with name radSpreadsheet.
    Imports Telerik.Windows.Documents.Spreadsheet.Model.DataValidation
    '...
    Dim dataValidationRuleCellIndex As New CellIndex(0, 0)
     
    Dim context As New NumberDataValidationRuleContext(Me.radSpreadsheet.ActiveWorksheet, dataValidationRuleCellIndex)
    context.InputMessageTitle = "Restricted input"
    context.InputMessageContent = "The input is restricted to whole number values between 0 and 100"
    context.ErrorStyle = ErrorStyle.[Stop]
    context.ErrorAlertTitle = "Wrong value"
    context.ErrorAlertContent = "The entered value is not valid. Allowed values are in the range between 0 and 100!"
    context.IgnoreBlank = False
    context.ComparisonOperator = ComparisonOperator.Between
    context.Argument1 = "0"
    context.Argument2 = "100"
     
    Dim rule As New WholeNumberDataValidationRule(context)
     
    Me.radSpreadsheet.ActiveWorksheet.Cells(dataValidationRuleCellIndex).SetDataValidationRule(rule)

    I hope this helps.

    Regards,
    Petya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. John
    John avatar
    8 posts
    Member since:
    Feb 2012

    Posted 09 Mar 2015 in reply to Petya Link to this post

    Ah ha.  Thanks for the reply.  I guess I overlooked the fact I was using the wrong version of the tools.  I did find a work around that was posted on another question that will have to do.

    Thanks.
Back to Top