由网友(余温.)分享简介:我有以下的code:ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match")ListBox.DisplayMember = "name"的DataTable.Select()方法返回数组System.Data....
我有以下的code:
ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match")
ListBox.DisplayMember = "name"
的DataTable.Select()方法返回数组System.Data.DataRow对象。
The DataTable.Select()
method returns an array of System.Data.DataRow
objects.
无论我在 ListBox.DisplayMember
属性来指定,我看到的是与项目无不呈现为的正确数量的列表框系统.Data.DataRow
,而不是我想要的值,它是在名称
列!
No matter what I specify in the ListBox.DisplayMember
property, all I see is the ListBox with the correct number of items all showing as System.Data.DataRow
instead of the value I want which is in the "name"
column!
是否可以结合从 DataTable.Select结果数组()
,而不是通过其循环和增加每个人的的ListBox
?
Is it possible to bind to the resulting array from DataTable.Select()
, instead of looping through it and adding each one to the ListBox
?
(我已经与循环没有问题,但似乎没有一个优雅的结局!)
(I've no problem with looping, but doesn't seem an elegant ending!)
推荐答案
使用数据视图的吧。
ListBox.DataSource = new DataView(DataSet.Tables("table_name"), "some_criteria = match", "name", DataViewRowState.CurrentRows);
ListBox.DisplayMember = "name"
相关推荐
最新文章