private void fpSpread1_EditChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
{
//货物规格根据combo.text筛选数据
FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxType = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxType2 = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
SqlDataReader MyDR = DbHelperSQL.ExecuteReader("select * from 物流规格表 order by 货品规格", null);
int m = Convert.ToInt32(DbHelperSQL.GetSingle("select count(规格ID) from 物流规格表 ", null).ToString());
int n = 0;
comboBoxType.Editable = true;
string[] items = new string[m];
while (MyDR.Read())
{
string Str = MyDR.GetString(2);
for (int i = 1; i < 2; i++)
{
Str = Str + " " + MyDR.GetValue(2 + i).ToString();
}
//if (Str.CompareTo(this.fpSpread1.ActiveSheet.ActiveCell.Text) == 1 || Str.CompareTo(this.fpSpread1.ActiveSheet.ActiveCell.Text) == 0)
if (this.fpSpread1.ActiveSheet.ActiveCell.Text.IndexOf(Str) > -1)
{
items[n] = Str;
n = n + 1;
}
}
string[] items2 = new string[n];
items2[0] = items[n - 1];
comboBoxType.Items = items2;
comboBoxType2.Clear();
comboBoxType2.Items = items2;
this.fpSpread1.Sheets[0].Columns[4].CellType = null;
this.fpSpread1.Sheets[0].Columns[4].CellType = comboBoxType2;
this.fpSpread1.Sheets[0].Columns[4].AllowAutoFilter = true;
this.fpSpread1.Sheets[0].Columns[4].AllowAutoSort = true;
this.fpSpread1.ButtonDrawMode = FarPoint.Win.Spread.ButtonDrawModes.CurrentRow;
AutoCompleteStringCollection acsc = new AutoCompleteStringCollection();
acsc.AddRange(items2);
comboBoxType2.AutoCompleteCustomSource = acsc;
comboBoxType2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBoxType2.AutoCompleteSource = AutoCompleteSource.CustomSource;
FarPoint.Win.FpCombo cmb = fpSpread1.EditingControl as FarPoint.Win.FpCombo;
我在fpSpread1_EditChange事件写的代码,想实现Combobox列模糊检索Combobox中的Items ,但是执行完出现未将对象引用到实例,帮我看看怎么个情况? |
|