如何在列表中绑定表< datarow>到datagridview [英] How do I bind table inside list< datarow > to datagridview
本文介绍了如何在列表中绑定表< datarow>到datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将在我的项目中使用linq。我的列表值来自数据集表:
I going to use linq in my project. my list value was taken from dataset table :
List <datarow> wareList = ds . tables["wareTable"] . AzEnumerable () . tolist () ;
,但是我无法将数据集中的表显示到datagridview中使用以下命令:
,but i cant display the table inside the dataset into datagridview With the following commands :
Var bindlist = new bindingList <datarow> ( warelist ) :
Var source = new bindingsource (bindlist , null) ;
Datagridview1 . datasource = source;
我的尝试:
What I have tried:
<pre>List <datarow> wareList = ds.tables["wareTable"] . AzEnumerable(). tolist() ;
Var bindlist = new bindingList <datarow> ( warelist ) :
Var source = new bindingsource (bindlist , null) ;
Datagridview1 . datasource = source;
推荐答案
DataGridView1.AutoGenerateColumns = true;
DataGridView1.DataSource = ds;
DataGridView1.DataMember = "wareTable";
或许你们可以使用:
Or maybe you can use:
DataGridView1.DataSource = Query.AsDataView();
请参阅:使用DataView过滤(LINQ to DataSet) Microsoft Docs [ ^ ]
这是一个支持Linq的自定义DataGridView: i00 BindingList with DataGridView [ ^ ]
See: Filtering with DataView (LINQ to DataSet) | Microsoft Docs[^]
Here is a custom DataGridView that supports Linq: i00 BindingList with DataGridView[^]
这篇关于如何在列表中绑定表< datarow>到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文