回复 1楼holly.huang的帖子
请参考:
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
- string[] cbstr;
- cbstr = new String[] { "王丽", "小明", "胡强", "王茜", "李晓东", "陈志成" };
- 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.Editable = true;
- //指定自动完成的模式及数据源
- combo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- combo.AutoCompleteSource = AutoCompleteSource.ListItems;
- fpSpread1.Sheets[0].Cells[0, 0].CellType = combo;
- fpSpread1.EditChange += fpSpread1_EditChange;
- }
- void fpSpread1_EditChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
- {
- if (this.fpSpread1.EditingControl!=null)
- {
- FarPoint.Win.FpCombo fpcombo = this.fpSpread1.EditingControl as FarPoint.Win.FpCombo;
- int curindex=0;
- for (int i = 0; i < fpcombo.ItemData.Count; i++)
- {
- if (fpcombo.ItemData[i].ToString().Contains(fpcombo.Text))
- {
- curindex = i;
- }
- }
- fpcombo.SelectedIndex = curindex;
- }
- }
复制代码 |