所以我在读在VB.NET文本框自动完成了一点,但我真的不能明白的地方,这些被存储?它是一个完全内置的功能,还是我必须写一些code为它工作?我发现文本框的 AutoCompleteMode 和 AutoCompleteSource 属性。但我想任何附加我写在文本框中自动完成源。难道我的源连接到 My.Settings 还是什么?难道不是我要使用一个数组中呢?任何帮助将是AP preciated:)
So I was reading a bit on AutoComplete of textboxes in VB.NET, but I can't really understand where these are stored? Is it a fully built in feature, or do I have to write some code for it to work? I've found the AutoCompleteMode and AutoCompleteSource properties of textboxes. But I want to append whatever I've written in the textbox to the autocomplete source. Do I connect the source to My.Settings or something? Wouldn't I have to use an array as well? Any help would be appreciated :)
推荐答案您将有新的条目添加到您的手动自动完成数据源...这是有道理的,当你想想:如何为Windows窗体咋办要知道,当一个新的项应该被添加到建议列表,当输入的文本只是暂时的东西?
You would have to add new entries to your auto-complete data source manually... which makes sense, when you think about it: How is Windows Forms supposed to know when a new entry should be added to the list of suggestions and when the text entered is only something temporary?
您可以添加如新价值当输入字段的验证情况,或者当用户presses一个OK / Apply按钮,或任何适合你的最好的。但是,你必须这样做你自己。
You could add new values e.g. when validation of the input field happens, or when the user presses an OK / Apply button, or whatever fits your need best. But you will have to do this yourself.
您已经发现的属性是正确的。
The properties you've already discovered are the right ones.
Dim suggestions As New List(Of String) suggestions.Add("Abba") suggestions.Add("Nirvana") suggestions.Add("Rolling Stones") ... textBox.AutoCompleteSource = suggestions您可以绑定 AutoCompleteSource 来几乎所有的东西;这是非常相似的数据绑定。有一点要记住的是,如果你要添加新条目自动完成数据源,UI控件可能不会立即注意到,如果你的数据源不落实 INotifyCollectionChanged 接口。
You can bind AutoCompleteSource to almost anything; this is very similar to data-binding. One thing to keep in mind is that if you're adding new entries to the auto-complete data source, the UI control might not immediately notice if your data source doesn't implement the INotifyCollectionChanged interface.
更多推荐
Vb.net +自动完成文本框中
发布评论