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); }
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); }