從字串集合中自動完成
var source = new AutoCompleteStringCollection();
// Add your collection of strings.
source.AddRange(new[] { "Guybrush Threepwood", "LeChuck" });
var textBox = new TextBox
{
AutoCompleteCustomSource = source,
AutoCompleteMode = AutoCompleteMode.SuggestAppend,
AutoCompleteSource = AutoCompleteSource.CustomSource
};
form.Controls.Add(textBox);
當使用者嘗試鍵入 G 或 L 時,這將自動完成。 **** ****
AutoCompleteMode.SuggestAppend
將顯示建議值列表,它將自動鍵入第一個匹配,Append
only 和 Suggest
也可用。