// [in designer] textBoxInContext.AutoCompleteMode = Suggest
// [in designer] textBoxInContext.AutoCompleteSource = CustomSource
AutoCompleteStringCollection autoComplete = new AutoCompleteStringCollection();
autoComplete.AddRange(myArrayofStrings);
textBoxInContext.AutoCompleteCustomSource = autoComplete;
我有這樣的代碼,它在MSDN中記錄的效果很好。
問題:如果用戶鍵入「PS」,它將顯示以「PS」開頭的所有字符串;我想顯示所有包含「PS」的字符串在winform中自動完成[包含而不是以開始] TextBox
任何指針?
這應該是一個相當簡單的任務,但我們需要查看更多代碼來確定要更改的行。類似於'var results = autoComplete.Where(x => x.StartsWith(「PS」);'變成'var results = autoComplete.Where(x => x.Contains(「PS」);' – JConstantine
@JLevett:這就是所有的代碼我試圖使用MS提供的自動完成功能[http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletemode%28v=vs.90%29 .aspx] – karephul
您可能需要查看[http://stackoverflow.com/questions/1524166/autocomplete-textbox-with-features-of-like-clause-example-hello-c-sharp-window]中的「相關鏈接「部分 - 看起來像這樣的行爲幾乎是不可能的 – jCoder