找回密码
 立即注册

QQ登录

只需一步,快速开始

zy2164867

中级会员

13

主题

27

帖子

756

积分

中级会员

积分
756

活字格认证

zy2164867
中级会员   /  发表于:2012-5-17 13:17  /   查看:10717  /  回复:19
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 ,但是执行完出现未将对象引用到实例,帮我看看怎么个情况?

19 个回复

正序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-3-2 15:59:46
20#
回复 使用道具 举报
szpzr
高级会员   /  发表于:2021-3-2 15:27:38
19#
版主:
       这个链接可以打开吗?
       谢谢!
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-21 17:59:00
18#
该问题我会在这个帖子中给你回复:http://gcdn.grapecity.com/showtopic-4513.html
回复 使用道具 举报
zy2164867
中级会员   /  发表于:2012-5-18 11:10:00
17#
如果你要实现只要输入字符出现在 Item 就显示该 Item ,只能重写一个 ComboBox/ComboBoxCeooType 控件
有现成的例子吗?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-18 10:55:00
16#
动态设置AutoCompleteCustomSource并不能实现你的需求,因为重新设置AutoCompleteCustomSource之后,ComboBox还是会充第一个字符开始比较,然后显示匹配成功的 Item
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-18 10:46:00
15#
zy2164867 你好

从你的需求来看,使用标准的ComboBox行为是找不到的,因为ComboBox/ComboBoxCeooType只能从第一个字符开始比较,然后显示符合的选项

如果你要实现只要输入字符出现在 Item 就显示该 Item ,只能重写一个 ComboBox/ComboBoxCeooType 控件
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-18 10:40:00
14#
Demo收到,正在查看中....
回复 使用道具 举报
zy2164867
中级会员   /  发表于:2012-5-17 21:50:00
13#

再帮我看下

我又用你做的改了下,我想达到这个效果:在第4列输入&quot;C&quot;下拉列表只有&quot;ABC&quot;, &quot;ACB&quot;, &quot;BCD&quot;这3个,就是下拉列表的ITEM根据下拉框的TEXT的变化而模糊搜索变化
DEMO.rar (301.04 KB, 下载次数: 189)
回复 使用道具 举报
zy2164867
中级会员   /  发表于:2012-5-17 21:50:00
12#

再帮我看下

我又用你做的改了下,我想达到这个效果:在第4列输入&quot;C&quot;下拉列表只有&quot;ABC&quot;, &quot;ACB&quot;, &quot;BCD&quot;这3个,就是下拉列表的ITEM根据下拉框的TEXT的变化而模糊搜索变化
DEMO.rar (301.04 KB, 下载次数: 195)
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部