如何在linq的combox中使用valuemember和dispaymember? [英] how to use valuemember and dispaymember in combox by linq?
本文介绍了如何在linq的combox中使用valuemember和dispaymember?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var E = (from em in employee.Employees
orderby em.EmployeeID
//where em.EmployeeID==1
select new { Names= em.FirstName,ID=em.EmployeeID }).ToList();
comboBox1.DisplayMember = " Names";
comboBox1.ValueMember = "ID";
comboBox1.DataSource = E ;
// its my code but comboBox don't fill like i want can any one help me ?
推荐答案
如果您确实复制并粘贴了代码,那么名称中的N前面就有一个空格。
If you've literally copied and pasted the code, you have a space before the N in Names.
不,这不是我的问题我的问题是组合框中的组合框显示ID和名称,我只想显示名称,值是ID如何?
no it's not my problem my problem is the combobox dispaly ID and Name in combobox and i want dispaly Name only and the value is ID how?
这篇关于如何在linq的combox中使用valuemember和dispaymember?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文