我有一个表“Clients”和一个名为tbClient的文本框,但我不知道如何使用实体框架和文本框上的LINQ实现自动完成。这就是我实际上
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;
填写datagridview
答案 0 :(得分:2)
我解决了
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;