This is a migrated thread and some comments may be shown as answers.

Validation on Spreadsheet

2 Answers 142 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 05 Mar 2015, 10:23 PM
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 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 09 Mar 2015, 02:48 PM
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.

 
0
John
Top achievements
Rank 1
answered on 09 Mar 2015, 04:21 PM
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.
Tags
Spreadsheet
Asked by
john
Top achievements
Rank 1
Answers by
Petya
Telerik team
John
Top achievements
Rank 1
Share this question
or