回复 1楼zjutwb的帖子
可以使用 DataValidator 实现这个Case,测试代码如下:
- public MainPage()
- {
- InitializeComponent();
- gcSpreadSheet1.HighlightInvalidData = true;
- var valid = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateListValidator("5,10,15,20");
- gcSpreadSheet1.Sheets[0].Cells[0, 1].DataValidator = valid;
- gcSpreadSheet1.Sheets[0].Cells[0, 0].Text = "5, 10, 15, and 20 are valid numbers.";
- var valid1 = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateNumberValidator(GrapeCity.Windows.SpreadSheet.Data.ComparisonOperator.GreaterThan, "5", "20", true);
- gcSpreadSheet1.Sheets[0].Cells[1, 1].DataValidator = valid1;
- gcSpreadSheet1.Sheets[0].Cells[1, 0].Text = "A number greater than 5 is valid.";
- var valid2 = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateTextLengthValidator(GrapeCity.Windows.SpreadSheet.Data.ComparisonOperator.GreaterThan, "4", "20");
- gcSpreadSheet1.Sheets[0].Cells[2, 1].DataValidator = valid2;
- gcSpreadSheet1.Sheets[0].Cells[2, 0].Text = "Type more than four characters.";
- }
- List<Cell> cells = new List<Cell>();
- private void gcSpreadSheet1_ValidationError(object sender, GrapeCity.Windows.SpreadSheet.UI.ValidationErrorEventArgs e)
- {
- cells.Add(this.gcSpreadSheet1.ActiveSheet.Cells[e.Row, e.Column]);
- }
复制代码 |