TextBox 智能感应
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 using System.Diagnostics; 11 using System.Windows; 12 13 namespace WindowsFormsApplication1 14 { 15 public partial class Form1 : Form 16 { 17 public Form1() 18 { 19 InitializeComponent(); 20 } 21 private void Form1_Load(object sender, EventArgs e) 22 { 23 // Create the list to use as the custom source. 24 var source = new AutoCompleteStringCollection(); 25 source.AddRange(new string[] 26 { 27 "January", 28 "February", 29 "March", 30 "April", 31 "May", 32 "June", 33 }); 34 textBox1.AutoCompleteCustomSource = source; 35 textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; 36 textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource; 37 } 38 } 39 }
TextBox.AutoCompleteMode 属性
属性成员:None, Suggest, Append, SuggesetAppend
TextBox.AutoCompleteSource 属性
属性成员:None, FileSystem, CustomSource, HistoryList, RecentlyUsedList, AllUrl, AllSystemSources, FileSystemDirectories
AutoCompleteMode 和 AutoCompleteSource 属性必须一起使用。
TextBox.AutoCompleteCustomSource 属性
这个用于TextBox.AutoCompleteSource 属性选择CustomSource时的数据源
AutoCompleteStringCollection 类
看看上面那个AutoCompleteCustomSource的类型就知道了,把数据源写在这里面