开发者

How to load a datatable into wpf data grid

开发者 https://www.devze.com 2023-01-24 08:34 出处:网络
I\'m tr开发者_开发知识库ying to display the content of a datatable in my wpf datagrid In the following post:

I'm tr开发者_开发知识库ying to display the content of a datatable in my wpf datagrid

In the following post:

Why can't I bind the WPFToolkit DataGrid ItemSource to DataTable?

I found the code:

myDataGrid.ItemsSource = myDataTable.DefaultView;

and the behaviour is strange: it shows n empty rows where the n is correct: the query results n rows!

So why can't I see them?


Without seeing the code, I would guess that you don't have AutoGenerateColumns set to to true. That's fine, but if you aren't auto-generating columns, you need to manually add column definitions to your data grid.


One possible solution would be to replace the DataGrid with a DataGridView and bind the DataGridView.DataSource property to the DataTable itself. As per this example:

dataGrid1.DataSource = table;

0

精彩评论

暂无评论...
验证码 换一张
取 消