C# winform 模仿百度文本框搜索出现问题
private void Form2_Load(object sender, EventArgs e)
{
AutoCompleteStringCollection myCutomSource = new AutoCompleteStringCollection();
myCutomSource.AddRange(new string[] { "北京理工", "北京师范", "北京航空", "清华大学" });
this.textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
this.textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
this.textBox1.AutoCompleteCustomSource = myCutomSource;
}
这样写完全正确
我想要加载数据库里面的 结果程序自动退出 有时“
尝试读取或写入受保护的内存。这通常指示其他内存已损坏” 错误
当然读取数据库时候 写在Form2_Load里面
并且 string select = "select top 10 Address from IdentityCard where Address like '%" + "北" + "%' ";
也正确 但是 只能输入一次 清空会报错 ,再次输入也报错
------解决方案--------------------请参考我的资源
TextBox和ComoBox智能提示功能源代码(类似Google首页的搜索框)http://download.csdn.net/source/1631570
------解决方案--------------------
AutoCompleteStringCollection AutoComp =;
txtbox1.AutoCompleteMode = AutoCompleteMode.Suggest;
txtbox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoComp.Add("1");
AutoComp.Add("2");
AutoComp.Add("3");
txtbox1.AutoCompleteCustomSource = AutoComp;
------解决方案--------------------顶一个,三分吧?唉。