我这边调试的结果如下,现在可以进行模糊查找,不过也丢失了一些ComboBox原有的特性,比如说键盘的上下键操作:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace DEMO
- {
- public partial class Form1 : Form
- {
- FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxType = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
- string[] ItemSource = new string[] { "AAA", "ABC", "AABC", "ACB", "BBB", "BCD", "AG" };
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- comboBoxType.Editable = true;
- comboBoxType.Items = ItemSource;
- comboBoxType.ListControl = new ListBox();
- this.fpSpread1.Sheets[0].Columns[4].CellType = comboBoxType;
- }
- private void fpSpread1_EditChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
- {
- if (e.Column == 4)
- {
- FarPoint.Win.FpCombo cbo = fpSpread1.EditingControl as FarPoint.Win.FpCombo;
- string[] items = (from item in ItemSource orderby item.ToUpper().IndexOf(fpSpread1.ActiveSheet.ActiveCell.Text.ToUpper()) where item.ToUpper().IndexOf(fpSpread1.ActiveSheet.ActiveCell.Text.ToUpper()) != -1 select item).ToArray<string>();
- if (items.Length > 0)
- {
- comboBoxType.Items = items;
- comboBoxType.MaxDrop = items.Length;
- cbo.ListControl.Items.Clear();
- cbo.ListControl.Items.AddRange(items);
- cbo.ShowList(true);
- cbo.SelectedItem = null;
- }
- else
- {
- comboBoxType.Items = ItemSource;
- comboBoxType.MaxDrop = ItemSource.Length;
- cbo.ListControl.Items.Clear();
- cbo.ListControl.Items.AddRange(ItemSource);
- cbo.ShowList(true);
- cbo.SelectedIndex = -1;
- }
- }
- }
- private void fpSpread1_EditModeOff(object sender, EventArgs e)
- {
- if (fpSpread1.ActiveSheet.ActiveColumnIndex == 4)
- {
- comboBoxType.Items = ItemSource;
- comboBoxType.MaxDrop = ItemSource.Length;
- comboBoxType.ListControl.Items.Clear();
- comboBoxType.ListControl.Items.AddRange(ItemSource);
- }
- }
- private void 调试ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- }
- }
- }
复制代码 |