Пример #1
0
        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            if (!(this.Focused || this.popup.Focused || this.list.Focused))
            {
                this.HideList();

                if (!IsAllowNotExists)//校验改信息是否存在
                {
                    if (this.Text.TrimEnd() != "")
                    {
                        this.selectedEntry = null;
                        bool bolExists = false;
                        foreach (AutoCompleteEntry entry in this.Items)
                        {
                            if (entry.DisplayName == this.Text.TrimEnd())
                            {
                                bolExists          = true;
                                this.selectedEntry = entry;
                                break;
                            }
                        }
                        if (!bolExists)
                        {
                            if (LB.WinFunction.LBCommonHelper.ConfirmMessage("所选择的内容不存在,请重新输入!", "提示", MessageBoxButtons.YesNo) ==
                                DialogResult.Yes)
                            {
                                this.Focus();
                            }
                            else
                            {
                                this.Text = "";
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        protected virtual AutoCompleteEntryCollection FilterList(AutoCompleteEntryCollection list)
        {
            AutoCompleteEntryCollection newList = new AutoCompleteEntryCollection();

            foreach (IAutoCompleteEntry entry in list)
            {
                AutoCompleteEntry autocom = (AutoCompleteEntry)entry;

                if (autocom.DisplayName.ToUpper().Contains(this.Text.ToUpper()))
                {
                    newList.Add(entry);
                }

                /*foreach (string match in entry.MatchStrings)
                 * {
                 *      if (match.ToUpper().StartsWith(this.Text.ToUpper()))
                 *      {
                 *              newList.Add(entry);
                 *              break;
                 *      }
                 * }*/
            }
            return(newList);
        }
Пример #3
0
        protected virtual AutoCompleteEntryCollection FilterList(AutoCompleteEntryCollection list, bool bolNeedFilter)
        {
            int    iFontMaxCount = 0;//最大字数
            string strMaxFont    = "";
            AutoCompleteEntryCollection newList = new AutoCompleteEntryCollection();

            foreach (IAutoCompleteEntry entry in list)
            {
                AutoCompleteEntry autocom = (AutoCompleteEntry)entry;

                if (autocom.DisplayName.Length > iFontMaxCount)
                {
                    iFontMaxCount = autocom.DisplayName.Length;
                    strMaxFont    = autocom.DisplayName;
                }

                if (!bolNeedFilter || autocom.DisplayName.ToUpper().Contains(this.Text.TrimEnd().ToUpper()))
                {
                    newList.Add(entry);
                }

                /*foreach (string match in entry.MatchStrings)
                 * {
                 *      if (match.ToUpper().StartsWith(this.Text.ToUpper()))
                 *      {
                 *              newList.Add(entry);
                 *              break;
                 *      }
                 * }*/
            }
            Graphics g        = this.CreateGraphics();
            SizeF    sizeFont = g.MeasureString(strMaxFont, this.Font);

            this.PopupWidth = Math.Max((int)sizeFont.Width, this.Width);
            return(newList);
        }
 public void Add(AutoCompleteEntry entry)
 {
     this.InnerList.Add(entry);
 }