Пример #1
0
        // 确保和当前日期有关的事项滚入视野
        public void EnsureCurrentVisible(DateTime?time)
        {
            if (time == null)
            {
                return;
            }

            if (this.orderDesignControl1.Items.Count > 0)
            {
                string strTime = DateTimeUtil.DateTimeToString8((DateTime)time);
                int    nCount  = 0;
                foreach (DigitalPlatform.CommonControl.Item item in this.orderDesignControl1.Items)
                {
                    if (item.InRange(strTime) == true)
                    {
                        this.orderDesignControl1.EnsureVisible(item);
                        this.orderDesignControl1.SelectItem(item, nCount == 0 ? true : false);
                        nCount++;
                    }
                    // TODO: 如果没有精确匹配的,还可以计算出和当前时间距离最近的
                    // 如果时间范围为空,还可以看订购时间
                }

                if (nCount == 0)
                {
                    DigitalPlatform.CommonControl.Item item = this.orderDesignControl1.Items[this.orderDesignControl1.Items.Count - 1];
                    this.orderDesignControl1.EnsureVisible(item);
                    this.orderDesignControl1.SelectItem(item, true);
                }
            }
        }