protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e); char ch = Convert.ToChar(13); // Enter\Action char chBack; // = Convert.ToChar(27); //Back key // Do nothing if the action key is pressed if (e.KeyChar == ch) { return; } // handle AutoNumbering if (autoNumbering) { //try to find the item int pressedKey = Convert.ToInt32(e.KeyChar.ToString()); this.SelectedIndex = pressedKey - 1; return; } string strLet = String.Empty; //letters from the pressed key if (!fullKeyboard) { chBack = Convert.ToChar(27); strLet = (string)numToLetter[e.KeyChar]; } else { chBack = (char)Keys.Back; strLet = e.KeyChar.ToString(); } if (savedItems.Count == 0) { savedItems = this.Items.CloneItems(); } string strSearch = ""; // Initialize helper arrays ArrayList tempArrSearch = (ArrayList)arrSearch.Clone(); ItemCollection filterItems = this.Items.CloneItems(); bTempCleaned = false; #region Back key if (e.KeyChar == chBack) //back key { if (searchBuffer.Count == 0) { return; } else { e.Handled = true; } arrSearch.Clear(); this.BeginUpdate(); OnFilteringStarted(null); if (searchBuffer.Count > 1) { ArrayList tmpSearch = (ArrayList)searchBuffer[searchBuffer.Count - 2]; for (int n = 0; n < tmpSearch.Count; n++) { strSearch = (string)tmpSearch[n]; if (strSearch.Length >= 1) { if (FilterItems(strSearch, savedItems)) { arrSearch.Add(strSearch); } } } searchBuffer.RemoveAt(searchBuffer.Count - 1); } else { searchBuffer.Clear(); PopulateItems(savedItems, 0); tempItems.Clear(); } OnFilteringComplete(null); if (tempItems.Count > 0) { PopulateItems(tempItems, strSearch.Length); } itemsMatched = tempItems.Count; this.EndUpdate(); this.EnsureVisible(0); return; } #endregion if (strLet == null) { return; } this.BeginUpdate(); arrSearch.Clear(); OnFilteringStarted(null); tempItems = ItemSearch(strLet, tempArrSearch); OnFilteringComplete(null); if (arrSearch.Count > 0) { searchBuffer.Add(arrSearch.Clone()); } else { //itemsMatched = 0; // string nomatch = "No matches:"; // this.Items.Clear(); // this.selected = 0; // this.Items.Add(new SmartListItem(nomatch)); // this.Invalidate(); // return; //tempItems.Clear(); //tempItems.Add("No matches:"); } if (tempItems.Count > 0) { PopulateItems(tempItems, searchBuffer.Count); } itemsMatched = tempItems.Count; this.EndUpdate(); this.EnsureVisible(0); }