蜂蜜柚子茶 发表于 2019-12-20 18:29:39

怎么做数据有效性

您好我想实现一个表格单元下拉的功能,类似excel的数据有效性,这个功能怎么做

dexteryao 发表于 2019-12-20 18:29:40

您好,和Excel一样,可以添加数据验证
gcSpreadSheet1.HighlightInvalidData = true;
var valid = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateListValidator("5,10,15,20");            
gcSpreadSheet1.Sheets.Cells.DataValidator = valid;
gcSpreadSheet1.Sheets.Cells.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.Cells.DataValidator = valid1;
gcSpreadSheet1.Sheets.Cells.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.Cells.DataValidator = valid2;
gcSpreadSheet1.Sheets.Cells.Text = "Type more than four characters.";
页: [1]
查看完整版本: 怎么做数据有效性