从字符串集合中自动完成

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

当用户尝试键入 GL 时,这将自动完成。 **** ****

AutoCompleteMode.SuggestAppend 将显示建议值列表,它将自动键入第一个匹配,Append only 和 Suggest 也可用。