我想知道如何使用户选择自动完成源,浏览并加载或导入文本文件导入的文本文件按顺序排列在fartextbox或其他东西。如果他想让编辑变得舒适和易于使用,那么即使可能吗?
答案 0 :(得分:2)
private void Form1_Load(object sender, EventArgs e)
{
// Create the list to use as the custom source.
var source = new AutoCompleteStringCollection();
source.AddRange(new string[]
{
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
});
// Create and initialize the text box.
var textBox = new TextBox
{
AutoCompleteCustomSource = source,
AutoCompleteMode =
AutoCompleteMode.SuggestAppend,
AutoCompleteSource =
AutoCompleteSource.CustomSource,
Location = new Point(20, 20),
Width = ClientRectangle.Width - 40,
Visible = true
};
// Add the text box to the form.
Controls.Add(textBox);
}
所以,你需要从某个地方获取建议到string []。它可以是一个字典,txt文件,二进制文件......一旦你将文字输入数组,你就可以了。