程序中有一个comboBoxEX ,经过绑定之后 text属性 有一个具体的值,但是 items.count==0 这是怎么回事?

解决方案 »

  1.   

    你问问comboBoxEX的作者,是不是忘记更新Count属性了
      

  2.   

    我是form_load 运行到最后一行,然后使用quick watch 查看,属性如上面所说,这是怎么回事
      

  3.   

    我没有用绑定,而是从结果集一条一条添加到combox 的
      

  4.   

     private void 录入保健EditForm_Load(object sender, EventArgs e)
            {
                this.textBox手牌编号.Text = this.acc.手牌编号;
                this.textBox保健名称.Text = this.保健点选.保健项.项目名称;
                DataBindTools.Bind_知识名称(this.comboBoxEx起钟类型, CommonConfigs.ProgId, "起钟类型");
                this.comboBoxEx起钟类型.SelectedIndex = 0;           
                this.BindComBox钟房编号();            this.OnRefresh();
            }        private void OnRefresh()
            {
                                       
                this.BindComBox技师(this.comboBox技师编号,this.comboBoxEx起钟类型.Text=="轮牌");            
                this.dateTimeInput落钟时间.Value = DateTime.Now;
                this.dateTimeInput起钟时间.Value = this.dateTimeInput落钟时间.Value.AddMinutes(-this.保健点选.保健项.时间);
            }-------------------------------
    private void BindComBox技师(ComboBox cbox, bool 轮牌)
            {
                cbox.Items.Clear();            if (轮牌)
                {              
                    保健价目DataSet.保健项目Row a = ConsoleService.Instance.保健价目DataSet.保健项目.First(p => p.项目名称 == this.textBox保健名称.Text);          
                    var q = from c in this.SpringDB.技师_排钟队列.Where(p => p.钟牌状态 == "正常")
                            join o in this.SpringDB.技师_当前状态.Where(p => p.当前状态 == "空闲") on c.技师编号
                            equals o.技师编号
                            select new
                            {
                                c.排队序号,
                                c.消费类别,
                                c.钟牌状态,
                                c.技师编号
                            };                if (q == null || q.Count() <= 0)
                        return;                if (q.Where(p => p.消费类别 == a.消费类别 && p.钟牌状态 == "正常").Select(p => p.排队序号).Count() > 0)
                    {
                        DateTime firstTime = (DateTime)q.Where(p => p.消费类别 == a.消费类别 && p.钟牌状态 == "正常").Select(p => p.排队序号).Min();
                        var f = q.Where(p => p.消费类别 == a.消费类别).FirstOrDefault(p => p.排队序号 == firstTime);                    cbox.Items.Add(f.技师编号);
                       
                    }
                }
                else
                {
                    foreach (技师_当前状态 s in this.SpringDB.技师_当前状态.Where(p => p.当前状态 == "空闲"))
                    {
                        cbox.Items.Add(s.技师编号);
                    }
                  
                }
                if (this.comboBox技师编号.Items.Count > 0)
                    this.comboBox技师编号.SelectedIndex = 0;
            }-----------------------------  private void comboBoxEx起钟类型_SelectedIndexChanged(object sender, EventArgs e)
            {
                const string 轮牌 = "轮牌";
                this.BindComBox技师(this.comboBox技师编号, this.comboBoxEx起钟类型.Text == 轮牌);
                //this.comboBox技师编号.Enabled = this.comboBoxEx起钟类型.Text == 轮牌 ? false : true;          
            }