C#:如何使用自定义自动完成源文本框

我想知道如何使用户选择自动完成源,浏览并加载或导入文本文件导入的文本文件按顺序排列在fartextbox或其他东西。 如果他想让编辑变得舒适和易于使用,那么即便可行吗?

仔细阅读文档https://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletemode%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

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文件,二进制文件……一旦你将单词输入数组,就可以了。