private void syntaxBoxControl1_KeyUp(object sender, KeyEventArgs e) { if (ShouldAutoCompleteShowForKeyTyped(e)) { originalList = mAutoCompleteManager.GetAutoCompleteValues(); if (originalList.Count != 0) { syntaxBoxControl1.AutoListClear(); syntaxBoxControl1.AutoListBeginLoad(); foreach (string s in originalList) { syntaxBoxControl1.AutoListAdd(s, -1); } syntaxBoxControl1.AutoListEndLoad(); syntaxBoxControl1.AutoListVisible = true; syntaxBoxControl1.AutoListPosition = syntaxBoxControl1.Caret.Position; if (originalList.Count != 0) { syntaxBoxControl1.AutoListSelectedText = originalList[0]; } } } else if (syntaxBoxControl1.AutoListVisible) { if (syntaxBoxControl1.Caret.CurrentWord != null) { string word = syntaxBoxControl1.Caret.CurrentWord.Text; if (word != "." && lastFilteredWord != word) { lastFilteredWord = word; List <string> filtered = new List <string>(); foreach (string s in originalList) { if (s.Contains(word)) { filtered.Add(s); } } syntaxBoxControl1.AutoListClear(); syntaxBoxControl1.AutoListBeginLoad(); foreach (string s in filtered) { syntaxBoxControl1.AutoListAdd(s, -1); } syntaxBoxControl1.AutoListEndLoad(); syntaxBoxControl1.AutoListAutoSelect = true; if (filtered.Count != 0) { // First we want to sse if we have any entries // that start with our current word. If not, then // we'll just pick the first item // Default to entry 0 int entryToShow = 0; for (int i = 0; i < filtered.Count; i++) { if (filtered[i].StartsWith(lastFilteredWord)) { entryToShow = i; break; } } syntaxBoxControl1.AutoListSelectedText = filtered[entryToShow]; } } } } }