[英]how do I link TextBox's AutoCompleteSource to entity framework
I've a table "Clients", and a textbox named tbClient, but i dont know how to implement autocomplete using entity framework and LINQ on the textbox. 我有一个表“ Clients”和一个名为tbClient的文本框,但我不知道如何使用文本框上的实体框架和LINQ来实现自动完成功能。 this is what i've actually 这就是我实际上
var client = from a in ca.Clients select new { a.Name, a.DNI, a.Address, a.Phone, a.Email};
var cli = client.ToList();
dgvClient.DataSource = cli;
to fill the datagridview 填充datagridview
i solved 我解决了
var name = from a in ca.Clients select a.Name;
AutoCompleteStringCollection sourcename = new AutoCompleteStringCollection();
sourcename.AddRange(name.ToArray());
this.tbName.AutoCompleteMode = AutoCompleteMode.Suggest;
this.tbName.AutoCompleteSource = AutoCompleteSource.CustomSource;
this.tbName.AutoCompleteCustomSource = sourcename;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.