本文阐述如何通过 ComboCellType 实现类似于实现像google 搜索一样的自动完成功能。
代码如下:
//设置单元格类型 FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType(); string[] cbstr; cbstr = new String[] { "AAA", "AABC", "ABBC", "BBB", "BBC", "BCC" }; string[] strval; strval = new String[] { "1", "2", "3", "4", "5", "6" }; combo.Items = cbstr; combo.ItemData = strval; combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData; //指定自动完成的模式及数据源 combo.AutoCompleteMode = AutoCompleteMode.SuggestAppend; combo.AutoCompleteSource = AutoCompleteSource.ListItems; fpSpread1.Sheets[0].Cells[0, 0].CellType = combo;
效果截图:
Demo下载: